开发者

django ignoring admin.py

开发者 https://www.devze.com 2023-02-01 05:13 出处:网络
I am trying to enable the a开发者_如何转开发dmin 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 am trying to enable the a开发者_如何转开发dmin 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 :)


Also: If you're adding the admin.py file with the dev server running, make sure to restart it. This tripped me up for a minute. :)

0

精彩评论

暂无评论...
验证码 换一张
取 消