在/ admin /找不到Django Admin'页面

时间:2010-11-13 20:46:12

标签: django django-admin django-views

我已取消注释settings.py和amp;中的管理区域urls.py.但管理员不会加载/ admin /。如果我将网址更改为/ 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}),
 )

感谢您的帮助!

1 个答案:

答案 0 :(得分:8)

user-profile的url模式与管理员发生冲突,当您将该模式移到最后时会发生什么,或者更好的是,将其作为r'^users/(?P<username>\w+)/$'的前缀