samedi 1 août 2015

Legitimate if condition skipping in Python [duplicate]

This question already has an answer here:

In my code, there is an if condition, which should be passed but is skipping for some reason. It looks like this:

 if request.method == 'POST':
        email = request.POST.get('email',None) #<-- abc@domain.com
        user = User.objects.get(username = request.user.username) 
        user_email = user.email                #<-- u''
        if user_email is None or '' and email is not None:
                user.email = email

The second if condition is skipping even though it's correct(user_email is empty string and email is not None). What am I doing wrong? I also tried splitting condition in two steps but it is still skipping.

Aucun commentaire:

Enregistrer un commentaire