我刚开始玩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.
这些是相关文件及其中的内容:
urls.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) )
admin.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
settings.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.奇怪.想法?
这是因为你离开了/
在urls.py
.将管理行更改为以下内容:
(r'^admin/(.*)', admin.site.root),
我在我的服务器上检查了这个并且从你的线路得到了同样的错误urls.py
.