if hasattr(form, 'name') and hasattr(form, 'date'):
print(form.name) #'Some name' - True
print(form.date) #none - False
This condition validates as True even if the hasattr(form, 'date')
is false.
What is the correct way to validate multiples hasattr?
hasattr
checks purely for existence. If it exists but is falsy it's still true. You may want a form ofgetattr
instead - but also double check you don't meanform.name
instead of justname
... – Loudermilk