Generic Views and Django.contrib.auth

90 views
Skip to first unread message

Rootz

unread,
Oct 16, 2014, 11:49:49 AM10/16/14
to django...@googlegroups.com
Can I use both Generic View and the Django.contrib.auth features (such as login_required decorator and other auth interface tool)? And if it is not possible to integrate auth into Generic Views then can you recommend alternative way of making the two work together? Adding to this I am using Django 1.7v and python 3.4v. 

Thank you

Vijay Khemlani

unread,
Oct 16, 2014, 12:54:45 PM10/16/14
to django...@googlegroups.com
If you are usign class based generic views you can use the decorators in the URL config of your app, for example

urlpatterns = patterns('',
    (r'^about/', login_required(AboutView.as_view())),
)


On Thu, Oct 16, 2014 at 12:49 PM, Rootz <arc4...@gmail.com> wrote:
Can I use both Generic View and the Django.contrib.auth features (such as login_required decorator and other auth interface tool)? And if it is not possible to integrate auth into Generic Views then can you recommend alternative way of making the two work together? Adding to this I am using Django 1.7v and python 3.4v. 

Thank you

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/09fe215a-4572-418c-959f-567e9ab05b0b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Rootz

unread,
Oct 19, 2014, 3:51:39 PM10/19/14
to django...@googlegroups.com
Thanks.

Rootz

unread,
Nov 30, 2014, 11:07:42 PM11/30/14
to django...@googlegroups.com
Hi can this work with url reversing namespaced urls?
thanks


On Thursday, October 16, 2014 11:54:45 AM UTC-5, Vijay Khemlani wrote:

Collin Anderson

unread,
Dec 2, 2014, 10:05:35 PM12/2/14
to django...@googlegroups.com
Hi,

It's probably possible. Do you mean url reversing the login view, or url reversing the view where login is required?

Collin

Marcus Cl

unread,
Dec 3, 2014, 10:10:31 AM12/3/14
to django...@googlegroups.com
yes
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/jgIW2u5T1P8/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> django-users...@googlegroups.com.
> To post to this group, send email to django...@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/2a61f4c5-4406-4dd3-a893-df18882d8684%40googlegroups.com.
Message has been deleted

Rootz

unread,
Dec 3, 2014, 10:13:24 AM12/3/14
to django...@googlegroups.com
URL Reversing the view where login is required.

Collin Anderson

unread,
Dec 4, 2014, 8:45:27 AM12/4/14
to django...@googlegroups.com
Hi,

Not sure about namespaces, but you can certainly use name:

urlpatterns = patterns('',
    url
(r'^about/', login_required(AboutView.as_view()), name='about'),
)

Or better yet, patterns() is deprecated so:

urlpatterns = [
    url
(r'^about/', login_required(AboutView.as_view()), name='about'),
]

Collin

Rootz

unread,
Dec 4, 2014, 8:34:36 PM12/4/14
to django...@googlegroups.com
Thanks . It work using both the name and namespaces.
Reply all
Reply to author
Forward
0 new messages