I have this view function that needs to send a flash message to a user when they sign up. Now that is running well but the problem is that I set an error message to show when the username or password is incorrect and its always showing there by default. Here is my code
views.py
def signup(request):
form = CreateUserForm()
if request.method == 'POST':
form = CreateUserForm(request.POST)
if form.is_valid():
form.save()
user = form.cleaned_data.get('username')
messages.success(request, 'An account was created for ' + user)
return redirect('login')
def login_user(request):
username = request.POST.get('username')
password =
request.POST.get('password')
user = authenticate(username=username, password=password)
if user is not None:
login(request, user)
return redirect('home')
else:
messages.info(request, 'Incorrect Username or Password')
And when I go to the login page its just showing me incorrect username or password even though I just got there
How can I make it to show only when the username or password is incorrect