[Python] avoiding /accounts/login/?next in django

Discussão em 'Python' iniciado por Stack, Julho 12, 2025.

  1. Stack

    Stack Membro Participativo

    urls.py

    #...
    from myapp.views import MyView
    from django.contrib.auth.decorators import login_required


    urlpatterns = [
    #....
    url(r'^terminator/', login_required(MyView.as_view()), name='sexy')

    ]


    views.py

    class MyView(View):


    def get(self, request):
    return render(request, 'itworks.html')



    I am accessing MyView class via Somelogin class which redirects to "terminator url". But the problem is: django redirects me to following url http://127.0.0.1:8000/accounts/login/?next=/terminator.

    Of course, this address is not defined and gives me 404.

    I played with LOGIN_REDIRECT_URL in settings, but this just brings more confusion to code. So is there anyway to avoid this "default/next" in django and just go to http://127.0.0.1:8000/terminator.

    Continue reading...

Compartilhe esta Página