This looks really ugly, it there a way to make it look more pythonic?
if self.cleaned_data['string1_val'] == '' and latestSI.string1_val is None :
if self.cleaned_data['string2_val'] == '' and latestSI.string2_val is None :
return False
elif self.cleaned_data['string2_val'] == latestSI.string2_val :
return False
else:
return True
elif self.cleaned_data['string1_val'] == latestSI.string1_val :
if self.cleaned_data['string2_val'] == '' and latestSI.string2_val is None :
return False
elif self.cleaned_data['string2_val'] == latestSI.string2_val :
return False
else:
return True
else:
return True
All your issues stem from
Nones. Clean them up and your logic becomes trivial.