- Where Developers Learn, Share, & Build Careers


I would like to allow the user to logout and redirect it directly to the login page. In the Django User Authenication page (https://docs.djangoproject.com/en/dev/topics/auth/),

  logout_then_login (request [, login_url]) logs out the user , Then the URL of the redirect URL on the login page: A default URL was not provided. Optional argument: login_url: Redirect the url of the login page to the default settings .LOGIN_URL if not supplied   

Then the problem is that I click on the page, instead of going to the login page, the page This page has reloaded.

My code is below:

  @login_required def Main (requested): "" "Main view" "path = reverse ('home', kwargs = {' Userpk ': request.user.pk}) HttpResponseRirectirect (path) @login_required def home (request, userpk): "" Home page view "" If int (userpk)! = Request.user.pk: Return Return HttpResponseForbidden (Request, 'lex / main.html', dictionary = {'user': request.user, 'userpk': userpk}) DRF logoutunin (request): " "Logout N login back" "Return logout_ then_login (request, login_url = main (request))   

I think I'm not making a mistake, where some guidance is needed. ..

You must enter the URL of the login page so that the line

  Return logout_ then_login (request, login_then = / l Login])   

Assume that / login is your login url, or you use reverse in the name of your login URL You can urls.py

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -