Comment Form

12 views
Skip to first unread message

Soumen Khatua

unread,
Apr 26, 2019, 6:51:57 AM4/26/19
to django...@googlegroups.com
Hi Folks,
I want to allow for those who are logged in if they are not logged then it will redirect to login page.
if any one have any code related to this concept please share with me. For better clarity please go through this link-
and then click add reviews.

Thank You.


Regards,
Soumen

Kayode Oladipo

unread,
May 3, 2019, 3:06:05 PM5/3/19
to django...@googlegroups.com
Hello!

Django has a simple solution to this.

Go to your settings.py and define the url path to your login page.

LOGIN_URL = "your url login path"

Then in your views.py
from django.contrib.auth.decorators import login_required


Wrap the desired function with this decorator,

@login_required
def the_function():
    


Hope this helps 

Cheers!

--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPUw6WY%3Dood%3Dpx1pgboLVj7%2BDrXhZj5r9%3DW5rPdA1iQ1cRageg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages