Jan-11-2023, 10:28 PM
Hello, I'm currently learning Django and i've come up with a difficulty. I have a login app, where the user logs in and registers, their url is localhost:8000/login. As soon as the user takes their login I want the URL to be localhost:8000/app. I tried to use LOGIN_REDIRECT_URL, but it didn't work. Any idea how I do that?
project/urls.py
project/urls.py
from django.contrib import admin from django.urls import path, include urlpatterns = [ path('', include('page.urls')), path('app/', include('home.urls'), name='home'), path('admin/', admin.site.urls), ]login/views.py
@login_required def user_logout(request): logout(request) return HttpResponseRedirect('/login/') def login_user(request): if request.method == "POST": username = request.POST.get("username") password1 = request.POST.get("password1") user = authenticate(request, username=username, password=password1) if(user): login(request, user) HttpResponseRedirect(settings.LOGIN_REDIRECT_URL)project/settings.py
LOGOUT_REDIRECT_url = '/' LOGIN_REDIRECT_URL = 'home' # nome da urlwhen I log in with the credentials the login page is rendered again