Re: Authenication for django.views.generic Views
On Thu, Apr 16, 2009 at 3:04 PM, Col Wilsonwrote: > Thanks all. I have some reading to do, but I have also noticed in the > meantime that generic views docs (http://docs.djangoproject.com/en/dev/ > ref/generic-views/#ref-generic-views) have a hook into the auth > system. Look for 'login_required'. Or, since login_required is a decorator, and since you can pass the actual callable view you want to use directly in a URL pattern, just apply login_required to a generic view in your URLConf. One example is described here (fourth section): http://www.b-list.org/weblog/2007/nov/06/urlconf/ -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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 -~--~~~~--~~--~--~---
Re: Authenication for django.views.generic Views
Thanks all. I have some reading to do, but I have also noticed in the meantime that generic views docs (http://docs.djangoproject.com/en/dev/ ref/generic-views/#ref-generic-views) have a hook into the auth system. Look for 'login_required'. Having said that, I still have a bit of reading to do. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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 -~--~~~~--~~--~--~---
Re: Authenication for django.views.generic Views
http://docs.djangoproject.com/en/dev/topics/auth/#limiting-access-to-generic-views hope this helps. Basically you write your own view which calls the generic view after you have done your authentication. On Apr 16, 11:25 am, Col Wilsonwrote: > I'm using generic views to render my pages > (django.views.generic.date_based, django.views.generic.list_detail > etc) and they're very handy. > > However, the app I'm trying to build would like a security and on > reading the "User Authentication in Django" document, it just talks > about adding authentication to the views. > > Generic views of course are buried in the django installation > directories and you don't want to go messing about in there, so it's > not obvious to me how I can do that. > > Can someone give me a hand please? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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 -~--~~~~--~~--~--~---
Re: Authenication for django.views.generic Views
On Apr 16, 4:25 pm, Col Wilsonwrote: > I'm using generic views to render my pages > (django.views.generic.date_based, django.views.generic.list_detail > etc) and they're very handy. > > However, the app I'm trying to build would like a security and on > reading the "User Authentication in Django" document, it just talks > about adding authentication to the views. > > Generic views of course are buried in the django installation > directories and you don't want to go messing about in there, so it's > not obvious to me how I can do that. > > Can someone give me a hand please? The basic way to do this is to write a simple view which is just a short wrapper around a generic view, but which takes authentication. James Bennett has a good post on this: http://www.b-list.org/weblog/2006/nov/16/django-tips-get-most-out-generic-views/ -- DR. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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 -~--~~~~--~~--~--~---
Re: Authenication for django.views.generic Views
On Thu, Apr 16, 2009 at 8:25 AM, Col Wilsonwrote: > > I'm using generic views to render my pages > (django.views.generic.date_based, django.views.generic.list_detail > etc) and they're very handy. > > However, the app I'm trying to build would like a security and on > reading the "User Authentication in Django" document, it just talks > about adding authentication to the views. > > Generic views of course are buried in the django installation > directories and you don't want to go messing about in there, so it's > not obvious to me how I can do that. > > Can someone give me a hand please? > > > Middleware would be one option. You could write a process_view function that checks request.user and redirects requests with no authentication. This will all happen before the view gets called. More here: http://docs.djangoproject.com/en/dev/topics/http/middleware/#process-view Colin --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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 -~--~~~~--~~--~--~---
Authenication for django.views.generic Views
I'm using generic views to render my pages (django.views.generic.date_based, django.views.generic.list_detail etc) and they're very handy. However, the app I'm trying to build would like a security and on reading the "User Authentication in Django" document, it just talks about adding authentication to the views. Generic views of course are buried in the django installation directories and you don't want to go messing about in there, so it's not obvious to me how I can do that. Can someone give me a hand please? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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 -~--~~~~--~~--~--~---