gpt4 book ai didi

django - 名称错误 :Admin not found in django

转载 作者:行者123 更新时间:2023-12-03 15:11:33 24 4
gpt4 key购买 nike

项目的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'^$', 'Sdr.views.home', name='home'),
# url(r'^Sdr/', include('Sdr.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)),
(r'', include('Sdr.sdr.urls')),
)

应用程序的 urls.py 看起来像这样
# Import django modules
from django.conf.urls.defaults import *
from django.contrib import admin
# Import custom modules
import settings


admin.autodiscover()
urlpatterns = patterns('',
url(r'^admin/', include(admin.site.urls)),
(r'', include('Sdr.sdr.urls')),
)

我得到的错误是发现异常是
Django Version: 1.3
Exception Type: NameError
Exception Value:
name 'admin' is not defined

最佳答案

您忘记导入 admin在项目的 urls.py 中。多读书。

关于django - 名称错误 :Admin not found in django,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6185771/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com