views:

278

answers:

1

Django's auth messages look pretty handy for notifying a CMS user of some configuration problem. The thing is that the messages are deleted on every page load if you include the "django.core.context_processors.auth" context processor, and you have to include that processor if you want to use the admin interface.

I tried hacking around it by adding that processor to TEMPLATE_CONTEXT_PROCESSORS just after matching the admin url / before calling admin.site.root, but it appears that it's already imported the list of processors by that time.

So is there any way to do this without changing any of the Django core files themselves, and without omitting the django Auth app from your config entirely until the last possible moment?

A: 

If the Django message system was critical for my site I would add the messaging into my views with, for example:

If you really need to hack it so they only show in admin pages then the easiest solution would be to copy the auth function in django.contrib.core.context_processors.py and put it into a context_processors.py in your own application directory. Use it in the CONTEXT_PROCESSORS stack instead of the django.core version and modify it so it looks at the REQUEST url and only calls user.get_and_delete_messages() if it is the admin url.

Van Gale