Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

django login required

from django.contrib.auth.decorators import login_required

@login_required
def my_view(request):
    # handle view
-------------------------------------------------------------------

# add in settings.py

LOGIN_URL = your_login-page_url

### now if the user attemped to request the view without login  ###
### user will be redirected to the login-page using the provided url in settings.py ###
 
PREVIOUS NEXT
Tagged: #django #login #required
ADD COMMENT
Topic
Name
9+4 =