0
In my application I am receiving from the user the day, month and year, the three fields are part of a form and are IntegerField
. I don’t want to use the DateField
, because the user has the options to inform:
- Year;
- Year and month;
- Year, month and day;
My idea is, after the user informs the data, validate them by calling the function valida_data
(created by me):
erro = form.valida_data()
Function valida_data
maid in the form
:
def valida_data(self):
if self.fields['mes'] == 2 or 4 or 5 or 6:
pass
But error occurs, because I’m comparing a IntegerField
with a int()
.
Can you help me in creating the validation function day, month and year? Know another way to perform the validation?
That your condition
if self.fields['mes'] == 2 or 4 or 5 or 6
, does not make sense. The correct, apparently, would beif self.fields['mes'] in (2, 4, 6)
. By the way, what is the mistake that gives?– Woss