我刚刚开始使用 Django,并根据我自己的一组基本要求松散地遵循本教程。到目前为止,我绘制的模型比教程更全面,但它们编译得很好。否则,一切都应该是一样的。
我的问题是管理应用程序。我可以登录并查看可编辑的模型,但是当我单击模型或任何更改/添加按钮时,我会得到 404。
这是我得到的确切错误:
Page not found (404)
Request Method: GET
Request URL: http://localhost:8000/admin/auth/user/add/
App u'', model u'auth', not found.
这些是相关文件以及其中的内容:
网址.py
from django.conf.urls.defaults import *
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
# Example:
# (r'^daso/', include('daso.foo.urls')),
# Uncomment the admin/doc line below and add 'django.contrib.admindocs'
# to INSTALLED_APPS to enable admin documentation:
#(r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
(r'^admin(.*)', admin.site.root)
)
管理员.py
from daso.clients.models import Person, Client, Contact
from django.contrib import admin
admin.site.register(Person)
admin.site.register(Client)
admin.site.register(Contact)
models.py - 我只展示一个模型
class Client(Person):
relationships = models.ManyToManyField("Contact", through="Relationship", null=True)
disabilities = models.ManyToManyField("Disability", related_name="disability", null=True)
medical_issues = models.ManyToManyField("MedicalIssue", related_name="medical_issue", null=True)
medicare_num = models.CharField(max_length=15, blank=True)
insurance = models.OneToOneField("Insurance", null=True, blank=True)
medications = models.ManyToManyField("Medication", through="Medication_Details", null=True)
def __unicode__(self):
client = u"[Client[id: ", self.id, " name: ", self.first_name, " ", self.last_name, "]"
return client
设置.py
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
'daso.clients',
)
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
)
这些应该是相关的文件/文件部分。如果有人知道为什么我会得到 404,请赐教?
请注意,在此处粘贴时,已安装的应用程序的最后 2 个应用程序带有选项卡,而不是间隔 *4,并且在重新加载管理页面时它工作了半秒,然后再次出现 404。奇怪的。想法?