I'm creating a login View in which soon after a user is authenticated I'm logging that user in by redirecting to 'dashboard' page but I also want to sent additional data about the user to the 'dashboard' page so that I can display it dynamically on the template. For this, I'm trying to send a model as a parameter in redirect but django is not displaying anything on the template.
if user is not None:
# authenticate the user
auth.login(request, user)
# Fetch additional information about the user
# fetching presonal-Information
try:
personal_info = PersonalInformation.objects.get(user_id=user.id)
except ObjectDoesNotExist:
personal_info = None
return redirect('dashboard', personal_info)
else:
messages.error(request, 'Invalid credentials')
return redirect('login')
else:
return render(request, 'pages/login.html')
Aucun commentaire:
Enregistrer un commentaire