In my Order model, I have two field Diagnosis_note and Internal_memo, if one of the fields is blank, I want to display a red button and a green button if both are blank. However, currently in my function, if Diagnosis_note or both fields are blank, it displays a green button and if Internal_memo field is blank is displays a red button. It should display a red button if either one of it is blank or not blank and green if both are blank. Something is wrong with my is_complete function, but I can't figure out what.
class Order(models.Model):
Diagnosis_note = models.CharField(max_length=30, blank=True)
Internal_memo = models.CharField(max_length=100, blank=True)
def is_complete(self):
fields_list = [self.Diagnosis_note, self.Internal_memo]
if self.Diagnosis_note or self.Internal_memo is None:
return True
else:
return False
html
{% if Order.is_complete %}
<td><a href="{% url 'accounts:special-notes' Order.id %}" class="btn btn-danger" role="button"><i class="fas fa-check-circle"></i></a></td>
{% else %}
<td><a class="btn btn-success" role="button"><i class="far fa-circle"></i> </a></td>
{% endif %}
self.Diagnosis_note or self.Internal_memo is Nonemeans "Diagnosis_note is considered True or Internal_memo is None", not "one of Diagnosis_note and Internal_memo is None".