Validate datetime in Django

Hi,
I have form with one datetime field.
How can i validate that date is valid (for example doesn’t have any letters) ?
I was trying do that by clean function in forms.py:
valid_date = isinstance(duel_date, datetime.datetime)
But is not working

Hi!

What’s not working? Do you have any error message? It’s not validating anything?

If you want to validate only one field, remember you need to create a method named clean_<your_field_name> inside your form. Validating a specific field

Also, if you’re using HTML templates, it’s good to define the field input type to leverage browser validations.
Take a look at this example of a datetime-local input (At the moment it only works with Chrome, Edge)

I got that problem, if i put i date field for example:
2021-05-03 22:18:10 abc
Then clean_<your_field_name> is not proceed becouse form is invalid (invalid input).

Ok. Did you check the form errors to see what’s making it invalid?