I am using Django with a MYSQL backend and I have noticed that there is a delay between when I update the data in my database and when the new data is available. Here is what's going on in my code:
def change_user_email_api(request):
logger.debug("API: resend verification email")
new_email = request.GET.get('email', '')
username = request.user.username
the_user = User.objects.get(username=username)
the_user.email = new_email
the_user.save()
send_verification_email(request.user)
return generate_success(callback)
send_verification_email sends out an email to the user to verify their email account. I'm thinking the error is due to me passing request.user instead of the_user to send_verification_email.
Is there any way that I an ensure that I always have the newest data from the db, and if so, should I be doing this anyway? Or should I just accept that the data will take some time to update and design around this?
Thanks!
save(). please provide more context, or a real example. (yours looks made up, e.g. you are missing the string quotes)