How to repair my login redirect in django

The urls in my django project started to fail. So in my templates I had to change {% url 'home' %} for {% url 'app1:home' %} and also my urls, so my urls works fine but not the redirect when log in or log out. I have

LOGIN_REDIRECT_URL = 'home'
LOGOUT_REDIRECT_URL = 'home'

But now I get NoReverseMatch, reverse from home don't work.

# my app1.urls.py
from django.urls import path
from .views import HomePageView, VentasPageView, AcercaPageView
from .views import buscar

app_name = 'app1'

urlpatterns = [
    path('', HomePageView.as_view(), name='home'),
    path('ventas/', VentasPageView.as_view(), name='ventas'),
    path('buscar', buscar, name='buscar'),
    path('acerca/', AcercaPageView.as_view(), name='acerca')
]

What should I do? Why is this happening?

1 answer

  • answered 2019-07-22 03:16 solarissmoke

    You need to make exactly the same change to your URL settings:

    LOGIN_REDIRECT_URL = 'app1:home'
    LOGOUT_REDIRECT_URL = 'app1:home'
    

    or provide actual URLs, e.g.,:

    LOGIN_REDIRECT_URL = '/'
    LOGOUT_REDIRECT_URL = '/'