Django Admin '在 /admin/ 中找不到页面
Posted
技术标签:
【中文标题】Django Admin \'在 /admin/ 中找不到页面【英文标题】:Django Admin 'Page not found at /admin/Django Admin '在 /admin/ 中找不到页面 【发布时间】:2011-05-09 15:28:39 【问题描述】:我在 settings.py 和 urls.py 中取消了管理区域的注释。但是管理员不会在 /admin/ 加载。如果我将 url 更改为 /admin/auth/ 那么我可以登录管理面板,但如果我尝试转到 /admin/ 它仍然找不到该页面。
这是我的 settings.py :
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.admin',
'src',
'lib.tagging',
'lib.markdown',
'lib.avatar',
# Uncomment the next line to enable admin documentation:
#'django.contrib.admindocs',
)
URLs.py
from django.conf.urls.defaults import *
from django.conf import settings
from src import views
from src.models import Want
from lib.tagging.models import Tag
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
want_info_dict =
'queryset': Want.objects.all(),
'date_field': 'pub_date',
urlpatterns = patterns('django.views.generic.simple',
url(r'^about/$', 'direct_to_template', "template":"about.html", name="about"),
)
urlpatterns += patterns('',
url(r'^$', views.home, name="home"),
url(r'^signup/$', views.signup, name="signup"),
url(r'^accounts/login/$', views.userlogin, name="login"),
url(r'^accounts/settings/$', views.account_settings, name="settings"),
url(r'^logout/$', 'django.contrib.auth.views.logout', "next_page":"/", name="logout"),
#user profile
url(r'^(?P<username>\w+)/$', views.userprofile, name="user-profile"),
#wants
url(r'^mentees/(?P<slug>[-\w]+)/$', views.wants_by_tag, name="wants_by_tag"),
url(r'^avatar/', include('lib.avatar.urls')),
# Uncomment the admin/doc line below to enable admin documentation:
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
url(r'^admin/', include(admin.site.urls)),
)
if settings.DEBUG:
urlpatterns += patterns('',
(r'^static/(?P<path>.*)$', 'django.views.static.serve', 'document_root': settings.MEDIA_ROOT),
)
感谢您的帮助!
【问题讨论】:
什么版本的django?你能显示 full urls.py 吗? 1.2.3 上面添加了完整的url 【参考方案1】:user-profile
的 urlpattern 与 admin 冲突,当您将该模式移到末尾时会发生什么,或者更好的是,将其添加为 r'^users/(?P<username>\w+)/$'
之类的前缀
【讨论】:
以上是关于Django Admin '在 /admin/ 中找不到页面的主要内容,如果未能解决你的问题,请参考以下文章