olamundo
olamundo

Reputation: 24991

django ignoring admin.py

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?

Upvotes: 6

Views: 1701

Answers (2)

starsinmypockets
starsinmypockets

Reputation: 2294

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. :)

Upvotes: 1

Silver Light
Silver Light

Reputation: 45982

You need to ensure you have app containing Poll listed in INSTALLED_APPS :)

Upvotes: 11

Related Questions