postgresql - Redirect me back to login page after clicking register button in my django application -


i stuck in piece of code don't messed real.any contribution appreciate .every time try access register form redirected login others working fine middleware.py file

import re django.conf import settings django.shortcuts import redirect django.urls import reverse django.contrib.auth import logout    exempt_urls = [re.compile(settings.login_url.lstrip('/'))] if hasattr(settings, 'login_exempt_urls'):     exempt_urls += [re.compile(url) url in settings.login_exempt_urls]   class loginrequiredmiddleware:      def __init__(self, get_response):         self.get_response = get_response      def __call__(self, request):         response = self.get_response(request)         return response     def process_view(self, request, view_func, view_args, view_kward):         assert hasattr(request, 'user')         path = request.path_info.lstrip('/ /')         print(path)          if not request.user.is_authenticated():             if not any(url.match(path) url in exempt_urls):                 return redirect(settings.login_url)          url_is_exempt = any(url.match(path) url in exempt_urls)          if path == reverse('logout').lstrip('/'):             logout(request)          if path == reverse('register').lstrip('/'):             register(request)          if request.user.is_authenticated() , url_is_exempt:             return redirect(settings.login_redirect_url)         elif request.user.is_authenticated() or url_is_exempt:             return none         else:             return redirect(settings.login_url) 

my settings.py

static_url = '/static/' static_root = os.path.join(base_dir, 'static') #login_redirect_url = '/account/' login_redirect_url = '/' #login_redirect_url = '/templates/blog/base.html/' #base_redirect_url = '/templates/blog/base.html/' #base_redirect_url = '/account/' #base_dir = '/templates/blog/base.html/' #login_url = '/blog/base.html/' #login_url = '/account/login/' #login_url = '/account/' login_exempt_url = (     r'^account/logout/$',     r'^account/register/$'     )  email_host = 'localhost' email_port = 1025 


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -