django忽略admin.py [英] django ignoring admin.py
问题描述
我尝试了以下教程( here ),其中说:
(Quote)
只需要做一件事情:我们需要告诉
管理员,Poll对象有
管理界面。为此,在您的民意调查
目录中创建一个名为admin.py的
文件,并将其编辑为
这样:
from polls.models import $从
django.contrib import admin
admin.site.register(Poll)
(结束报价)
一个 admin.py
文件,并在 urls.py
中添加以下行:
从django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
...
(r'^ admin /',include(admin.site.urls)),
)
但似乎没有任何效果。我甚至在 admin.py
的第一行添加了一个 print 1
,我看到打印输出从不发生,所以我猜django不知道我的 admin.py
。如上所述,我可以进入管理员网站,只是看不到组,用户和网站之外的任何内容。
我缺少什么步骤?
你需要确保你有包含在INSTALLED_APPS中列出的投票的应用程序: / p>
I am trying to enable the admin for my app. I managed to get the admin running, but I can't seem to make my models appear on the admin page. I tried following the tutorial (here) which says:
(Quote)
Just one thing to do: We need to tell the admin that Poll objects have an admin interface. To do this, create a file called admin.py in your polls directory, and edit it to look like this:
from polls.models import Poll from
django.contrib import admin
admin.site.register(Poll)
(end quote)
I added an admin.py
file as instructed, and also added the following lines into urls.py
:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
...
(r'^admin/', include(admin.site.urls)),
)
but it appears to have no effect. I even added a print 1
at the first line of admin.py
and I see that the printout never happens, So I guess django doesn't know about my admin.py
. As said, I can enter the admin site, I just don't see anything other than "groups", "users" and "sites".
What step am I missing?
You need to ensure you have app containing Poll listed in INSTALLED_APPS :)
这篇关于django忽略admin.py的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!