【问题标题】:404 when enabling admin with Django使用 Django 启用管理员时出现 404
【发布时间】:2012-07-24 16:01:02
【问题描述】:

我已经正确配置了一个 Django 应用程序并让它运行顺利。但是,当我去启用管理面板时,我在取消注释此行时遇到了 404 错误:

url(r'^admin/', include(admin.site.urls))

在尝试访问我的网站时,我收到了以下信息:

Using the URLconf defined in cms.urls, Django tried these URL patterns, in this order:

    1. ^admin/

The current URL, , didn't match any of these.

我不知道如何解决这个错误。有一些 Django 经验的人有解决方案吗?谢谢!

编辑:这是整个urls.py 文件:

from django.conf.urls.defaults import patterns, include, url

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
    # Examples:
    # url(r'^$', 'cms.views.home', name='home'),
    # url(r'^cms/', include('cms.foo.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)),
)

【问题讨论】:

  • 目前看来,您即将匹配 '',您的整个 urls 文件是什么样的?您访问的是哪个网址,yourdomainyourdomain/yourdomain/admin
  • 您好,我在编辑中发布了整个 urls.py。当我转到 mydomain.com 时出现错误,但是当我转到 mydomain.com/admin 时,出现 500 内部服务器错误
  • 检查您在settings.py 中的INSTALLED_APPS 中列出了'django.contrib.admin'
  • 你使用的是哪个版本的 django?
  • 您在/ 获得了 404,因为您没有定义 urlpattern 来处理它。在/admin/ 你得到一个500,所以那是你的问题。发布该 500 错误的回溯。你为什么要问 404?

标签: python django django-admin


【解决方案1】:

你试过了吗,http://yourdomain:port/admin?如果您使用默认网址,我会尝试 http://127.0.0.1:8000/admin

【讨论】:

    猜你喜欢
    • 2012-07-05
    • 2021-08-18
    • 1970-01-01
    • 2017-12-01
    • 2012-03-06
    • 2013-07-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多