This seems like a simple question but I can’t seem to find a simple answer. Django seems to give this nifty simple way of limiting access to places using the permission required or login required decorators but I can’t see from the Django docs how one would pass an error message (maybe using the messages framework). If I have to roll my own decorator to do this, what is the point of the django decorators? Do they just not show any error messages?
Share
I’ll assume you simply avoided reading this
http://docs.djangoproject.com/en/1.2/topics/auth/#the-login-required-decorator
There are no “error messages”. Error messages are rude. And largely useless. They’re often a sign of bad design.
Generally, you don’t need a million tiny little explanations. Indeed, the default login page works fine for 80% of the use cases.
If you need to clarify the situation, you can provide your own HTML form. You can use the ordinary template context to add additional information. You have the Messages Framework for presentation of extra messages on the login page.