I remember using a middleware with an exception list. (more than a year ago)
On 10-12-18 05:35, Łukasz Rekucki wrote:
On 18 December 2010 13:48, James Bennett<ubernost...@gmail.com> wrote:
On Fri, Dec 17, 2010 at 8:43 PM, suckerfish<yip...@gmail.com> wrote:
I've added a decorator to *each* def in views.py to require
authentication. Is there a simpler way that allows me to apply
authentication automatically to every def in the file?
1. Write a middleware which will force authentication on all your
views (easy), or
You just have to remember to exclude the login view somehow. This is
troublesome if you want to use a 3rd party app for authentication.
Using decorator like @login_not_required will make you fork it. Second
options is to hardcode excluded views in the middleware. I had this
problem too and decided to bite the bullet for the sake of simplicity.
2. If you absolutely must have this happen at the view level, stick
some code in the views file which loops over the views defined in the
file and applies the auth decorator to each one.
Now that's some "automagic" :). IMHO, putting a single line in front
of a view isn't THAT bad and gives important information to the person
reading the code.
--
blog http://piotr.zalewa.info
jobs http://webdev.zalewa.info
twit http://twitter.com/zalun
face http://www.facebook.com/zaloon
--
You received this message because you are subscribed to the Google Groups "Django
users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.