I have two function. My first function updating an Boolean filed True to False. My first function working properly but my second function not updating object False to True. If I try two time then second time my second function updating object False to True. I am not understanding why it’s not updating at first time?
here is my code:
function1 #this function working properly
views.py
def ForgetPassword(request):
if request.method == "POST":
.....my others code
profile_obj = UserProfile.objects.get(user=user_obj)
profile_obj.email_confirmed = False
profile_obj.save()
.....my others code
function2 #this function not working properly If I try two time then second time my this function updating object False to True:
class ChangePassword_link(View):
#my others code....
if user is not None and account_activation_token.check_token(user, token):
profile_obj = UserProfile.objects.filter(user=user).update(email_confirmed = True)
messages.success(request, ('Your account have been confirmed. Now you can login'))
return redirect('members:change-password-page')
else:
messages.warning(request, ('The confirmation link was invalid, possibly because it has already been used.'))
return redirect('members:change-password-page')
#my others code....
The default value is false for email_confirmed fields in my model.