Apps won't show in Django admin
Asked Answered
I

9

8

I've read all the other threads but I still don't get why my apps are not showing up in Django admin. Everything else works fine.

My apps are in settings.py

I have admin.autodiscover in my root urls.py file

from django.conf.urls.defaults import *
from django.conf import settings

from django.views.generic.simple import direct_to_template

from django.contrib import admin

admin.autodiscover()



urlpatterns = patterns('',
url(r'^$', direct_to_template, {
    "template": "homepage.html",
}, name="home"),

url(r'^admin/invite_user/$', 'signup_codes.views.admin_invite_user', name="admin_invite_user"),
url(r'^account/signup/$', "signup_codes.views.signup", name="acct_signup"),

(r'^account/', include('account.urls')),
(r'^profiles/', include('basic_profiles.urls')),
(r'^notices/', include('notification.urls')),
(r'^announcements/', include('announcements.urls')),
(r'^tagging_utils/', include('tagging_utils.urls')),
(r'^attachments/', include('attachments.urls')),
(r'^comments/', include('threadedcomments.urls')),
#
(r'^wayfinder/', include('wayfinder.urls')),
(r'^site/', include('jsite.urls')),
(r'^kiosk/', include('kiosk.urls')),
(r'^navigator/', include('navigator.urls')),
(r'^location/', include('location.urls')),
(r'^event/', include('event.urls')),
#(r'^news_reader/', include('news_reader.urls')),
#(r'^weather_reader/', include('weather_reader.urls')),

(r'^admin/(.*)', admin.site.root),
)

if settings.SERVE_MEDIA:
urlpatterns += patterns('',
    (r'^site_media/', include('staticfiles.urls')),
)

All my apps have an admin.py file containing something like

from django.contrib import admin
from event.models import Event

class EventAdmin(admin.ModelAdmin):
    list_display = (
                'short_name',
                'long_name',
                'locations',
                'categories',
                'description',
                'phone',
                'email',
                'url_source',
                'url_location',
                'external_ref',
                'show_event'
            )

admin.site.register(Event, EventAdmin)

And I have restarted the server over and over ;-)

I am building on top of Pinax, but from my reading, it shouldn't change anything. Any clue what might be wrong ?

Ileac answered 4/1, 2010 at 21:57 Comment(3)
The usual reason is that settings.py does not mention the apps in the INSTALLED_APPS section, as Code Duck says. Do you have this set up correctly?Kami
Have you done syncdb ?Eastnortheast
figured out the problem. one of my admin was refering to deprecated newforms, I didn't butter fixing it right away. It seems that the second time (refreshing page) the admin was called, the error was dropped and the admin showed but without all the models that were following the one containing the error. as it was at the top of the apps I've added, none were show except the Pinax apps that were at the top of the list. never dismiss errors ;-) I'll give it to code duck thanks to all who helped ;-)Ileac
B
10

Do you have your apps in the INSTALLED_APPS section in settings.py? Make sure it has your apps listed there. My section reads

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.admin',
'django.contrib.sites',
'squick.items',
'cowsite.search',
'cowsite.posts',

)

for instance. I'm pretty sure for security, they won't show up in the admin unless they are in installed apps. I think I had this same issue, where I couldn't get cowsite to show up in the admin.

The Django docs say about the admin page: "By default, it displays all the apps in INSTALLED_APPS that have been registered with the admin application, in alphabetical order"

Berate answered 4/1, 2010 at 22:4 Comment(2)
the apps are in the installed_apps list. I should not that the whole project work, all the models from my apps are generated correctly and works in different views and 10s of templates, but I don't see them in the admin...Ileac
add admin.site.register(ThisModel) to your admin.py file in your app folder.Multiparous
S
7

By coincidence I had the same problem this morning. Briefly, this is what worked for me (see references for details):

In the top level directory of MyApp (ie same directory as models.py, etc.) I added a python module admin.py, containing:

from models import ThisModel, ThatModel
from django.contrib import admin

admin.site.register(ThisModel)
admin.site.register(ThatModel)

Then in mysite directory I did syncdb and runserver, and ThisModel and ThatModel were in the admin interface.

Does that work for you?

Best wishes

Ivan

** References

(I am a new member so I am allowed to post one hyperlink only!)

Django tutorial: Make the poll app modifiable in the admin

There was also a query on the Pinax google group recently titled, "How to add my app to Admin in a Pinax project?"

Sweptback answered 8/1, 2010 at 11:33 Comment(0)
S
5

Are you logging in to admin as a superuser? If not, it could be a permissions problem.

Subalternate answered 4/1, 2010 at 21:59 Comment(5)
Not everyone who can log in to admin has is_superuser right. Doublecheck that you do.Subalternate
Yes, logged in with super_user privilegesIleac
Notably, a user can login to the admin without is_superuser, and may only see some apps/models. (I was stumped by this problem for a bit, where my user who was is_staff and is_admin could see some but not all apps/models in the admin. When I made sure I was also is_superuser, everything expected appeared.)Mingle
It is not so much of a bug but a feature. That's the whole idea of superuser - to see all apps. While normal admin staff only see what they're allowed to see. Which apps/models are visible for non-superuser is controlled by permissions model.Subalternate
Anybody who has read this far should take a moment to lay eyes on the permissions! I was fairly certain I was a superuser and I was wrong! I wasted a lot of time as a result...Padgett
A
0

Not sure which version of django you're using but the current docs suggest including the admin urls.

 ('^admin/', include(admin.site.urls))
Acolyte answered 5/1, 2010 at 2:46 Comment(1)
I think that comes from pinax. The problem is not acessing the admin, that i can. It's really having acess to my app's models. ThanksIleac
O
0

For other's coming across this, I had the same issue due to grappelli.dashboard being in the installed apps but not actually installed in the virtualenv, so do a pip freeze and ensure all your requirements are actually installed.

Olnton answered 25/5, 2013 at 15:48 Comment(0)
Z
0

add your app name in "settings.py" file installed app.

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'myapp',


]
Zygo answered 20/8, 2019 at 13:16 Comment(0)
T
0

If the other solutions did not work for you, try to load your admin dashboard in a different browser. One of my apps was not displaying on the admin dashboard while I was using Google Chrome. After trying multiple answers others suggested, I decided to use Firefox instead. Voila! I was finally able to see my app on the admin dashboard.

Taeniafuge answered 15/11, 2021 at 15:20 Comment(0)
C
-1

You didn't answer Antony's question. Are you logging in as a superuser, or at least with a user with add/edit rights for the applications? If not, you won't see them.

Canaan answered 5/1, 2010 at 9:4 Comment(0)
A
-2

I had the same problem, what worked for me was changing this line in urls.py:

url(r'^admin/', include(admin.site.urls)),

to

url('^admin/', include(admin.site.urls)),

(Removing the r in the first bit of code) For some reason I am not aware of, the Polls became visible in admin after that.

Armstrong answered 11/9, 2013 at 10:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.