python – 为什么Django 1.0管理应用程序不工作?
发布时间:2020-12-16 21:38:31 所属栏目:Python 来源:网络整理
导读:我刚开始玩Django,并且根据我自己的一套基本要求松散地遵循教程.到目前为止我所描述的模型比教程更全面,但它们编译得很好.否则,一切都应该是一样的. 我的问题是管理员应用程序.我可以登录并查看可编辑的模型,但是当我点击模型或任何更改/添加按钮时,我会得到
我刚开始玩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.奇怪.想法? 解决方法
这是因为你遗漏了一个/ in urls.py.将管理行更改为以下内容:
(r'^admin/(.*)',admin.site.root), 我在我的服务器上检查了这个,并从urls.py中获取了相同的错误. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |