To redirect user to his custom page after login with Python Django, we can use the HttpResponseRedirect
class.
For instance, we write
from django.http import HttpResponseRedirect
from django.urls import reverse
from django.contrib.auth.decorators import login_required
@login_required
def home(request):
return HttpResponseRedirect(
reverse(NAME_OF_PROFILE_VIEW,
args=[request.user.username]))
to create the HttpResponseRedirect
object with the path of the view that we get from
reverse(NAME_OF_PROFILE_VIEW, args=[request.user.username])
The args
argument has the URL parameters.