[Fixed]-Registered models do not show up in admin

44πŸ‘

βœ…

After adding and registering your admin:

# app/admin.py
class YourModelAdmin(admin.ModelAdmin):
    pass

admin.site.register(YourModel, YourModelAdmin)

Make sure your app is in your project settings.py:

# settings.py
INSTALLED_APPS = (
    # other apps ...
    'app',
)

Sync your project for that model if you have not done so already:

python manage.py syncdb

Restart your server, CTRL-C:

python manage.py runserver
πŸ‘€Thierry Lam

13πŸ‘

In such a situation is also a good practice to check if the user logged in to the admin panel has rights to manage such a model. If they do then you could change your code to access the functions as root.

8πŸ‘

When in doubt, shut down server, syncdb, start server.

πŸ‘€M. Ryan

4πŸ‘

I have the experience, that sometimes after changing an admin.py the dev-sever won’t be restarted. in that case touch settings.py helps.

2πŸ‘

I think the checklist in Thierry’s answer is almost definitive, but make sure that urls.py contains admin.autodiscover() to load INSTALLED_APPS admin.py modules.

# urls.py
from django.conf.urls.defaults import *
from django.contrib import admin

admin.autodiscover()

urlpatterns = patterns('',
    ('^admin/', include(admin.site.urls)),
)

More info in the django docs.

πŸ‘€Alasdair

1πŸ‘

Have you added the application to your installed apps? That has happened to me both one and two times. πŸ™‚ Otherwise it would be useful for us to see the code to help you.

πŸ‘€rinti

1πŸ‘

Also make sure there are no syntax errors in your admin.py or anything. That can cause an app to fail to be registered with the AdminSite.

πŸ‘€Josh Ourisman

0πŸ‘

I’ve faced the same problem, but it was a little tricky than yours.

Consider, that you have a project with, say, five or even more apps. For me it is more obvious to register all models in just one admin.py file, so I have decided to do it in one place – core directory. Of course, it was not an app, so none of models showed up on admin page.

πŸ‘€JohnShallow

-1πŸ‘

comment out the some lines in urls.py see docs for more details

admin.autodiscover()

urlpatterns = patterns('',
    ('^admin/', include(admin.site.urls)),
)
πŸ‘€ha22109

Leave a comment