Login in all pages

53 views
Skip to first unread message

Juan Diego Gonzalez

unread,
Feb 5, 2015, 8:35:09 AM2/5/15
to django...@googlegroups.com
Hi, I need to put the django login feature in all pages, I mean, the user will be able to login in the reserved area of the web from any public page.

I have all the implementation done, and it works with a single page, in this way:
url(r'^home/$', magic.views.login, {'template_name':'magic/index.html'}),

I have put the code in a template, and it works only with home page, that is logical. Could anyone help me, please. I doesn't find any documentation.

May be something like url(r'^*/$', magic.views.login, {'template_name':'magic/index.html'}),

where * means any page.

Thank you very much.

Diego.

Kristofer Pettijohn

unread,
Feb 5, 2015, 8:20:19 PM2/5/15
to django...@googlegroups.com
I think the login decorator may give you what you are trying to do in a much easier way: https://docs.djangoproject.com/en/1.7/topics/auth/default/#limiting-access-to-logged-in-users

Unless I am not understanding your issue.


From: "Juan Diego Gonzalez" <juag...@gmail.com>
To: django...@googlegroups.com
Sent: Thursday, February 5, 2015 7:35:09 AM
Subject: Login in all pages

--
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/d44e8397-4b0a-4056-8f48-908793762ff4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Nelson Varela

unread,
Feb 6, 2015, 9:02:49 AM2/6/15
to django...@googlegroups.com
Take a look at middleware.

You can create a middleware which runs for every request. In 'process_request' you can check if the user is authenticated. If not... show or redirect to the login view.

The advantage is that you don't have to worry about placing decorators above your views.

Scot Hacker

unread,
Feb 7, 2015, 3:50:26 AM2/7/15
to django...@googlegroups.com


On Thursday, February 5, 2015 at 5:35:09 AM UTC-8, Juan Diego Gonzalez wrote:
Hi, I need to put the django login feature in all pages, I mean, the user will be able to login in the reserved area of the web from any public page.


Install django-stronghold or similar.

That'll lock down the entire site to registered users only. You can exempt any URLs that need to  be publicly accessible.

./s
 
Reply all
Reply to author
Forward
0 new messages