在 Django 上保存自定义模型管理员时出错



我正在使用Django 2.0开发一个Web,我有一个奇怪的(和烦人的(问题,这在开发环境中是不存在的。

我在 myweb.com/admin,保存数据,它有一个ImageField,当我保存Django时告诉我:

Page not found (404)
Request Method: POST
Request URL:    http://www.myweb.com/admin/about/about/add/
Raised by:  django.contrib.admin.options.add_view
Using the URLconf defined in myweb.urls, Django tried these URL patterns, in this order:
busqueda/
contacto/
sobre-mi/
admin/
[name='home']
<slug:categoria>/ [name='category']
<slug:category>/<slug:slug>/ [name='post']
^media/(?P<path>.*)$
The current path, about/about/add/, didn't match any of these.

我之所以提到ImageField,是因为没有这个Field的两个模型都没有问题。

这是myproject/urls.py:

from django.contrib import admin
from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
path('busqueda/', include('search.urls')),
path('contacto/', include('contact.urls')),
path('sobre-mi/', include('about.urls')),
path('admin/', admin.site.urls),
path('', include('post.urls')),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

关于/网址.py:

from django.urls import path
from .views import AboutView
app_name = 'about'
urlpatterns = [
path('', AboutView.as_view(), name='about-me'),
]

我无法自己解决这个问题。

编辑:关于/管理员.py

from django.contrib import admin
from .models import About
# Register your models here.
class AboutAdmin(admin.ModelAdmin):
readonly_fields = ('created', 'updated')
# Inyectamos nuestro fichero css
class Media:
css = {
'all': ('core/css/custom_ckeditor.css',)
}
admin.site.register(About, AboutAdmin)

编辑2:我已经从模型中删除了图像字段,并且保存正确

解决了,问题是我的托管公司为我提供的 Python 版本。他们只有python 3.4,但Django的版本需要的python 3.5更少。我在另一家企业尝试过,它运行良好。

最新更新