alesdotio / django-admin-shortcuts

Add simple and pretty shortcuts to the django admin homepage.
Other
205 stars 53 forks source link

KeyError at /admin/ #9

Closed joegillon closed 11 years ago

joegillon commented 11 years ago

I've customized my admin app. Copied base.html, base_site.html and index.html to my app. Shortcuts doesn't work at all when you do that - the settings are just ignored. So I copied index.html, templates/admin_shortcuts, static/admin_shortcuts, static/.DS_Store and the template_tags folder to my app. Now I get KeyError at /admin/:

Error during template rendering In template c:\shop\ccmr-joe\templates\admin\index.html, error at line 8

joegillon commented 11 years ago

Progress... I can get shortcuts to work on a project without a custom admin app by adding this to settings.py:

TEMPLATE_CONTEXT_PROCESSORS = ( 'django.contrib.auth.context_processors.auth', 'django.core.context_processors.request', )

Now, with the customized admin app I get

settings.ADMIN_SHORTCUTS is improperly configured

And the location is

C:\Python27\lib\site-packages\admin_shortcuts\templatetags\admin_shortcuts_tags.py in admin_shortcuts, line 26

So it seems it's not seeing my copied admin_shortcuts. Stay tuned...

joegillon commented 11 years ago

Uh oh. Looks like I simply had some sort of typo in my ADMIN_SETTINGS. Works fine now on projects with custom admin or not custom admin. Just needed the TEMPLATE_CONTEXT_PROCESSORS bit.

joegillon commented 11 years ago

OK, maybe the last word on this. Turns out all I needed from admin_shortcuts on a customized admin app was the index.html file. I had made a copy of the Django admin version and edited it. Of course, I lost that edit when I replaced it with the admin-shortcuts index.html file. When I switch back to it I lose the shortcuts. So, simply copy the admin_shortcuts index.html instead of the Django one, and edit it.

To summarize, I needed the admin_shortcuts index.html plus the above TEMPLATE_CONTEXT_PROCESSORS stuff.