django忽略admin.py [英] django ignoring admin.py

查看:220
本文介绍了django忽略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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆