Skip to content Skip to sidebar Skip to footer

ValidationError With Datatime Field In Django

I am working with the date picker of Tempus Dominus Bootstrap 4 in my Django project. template's date-picker link: Doc in my models.py: class Industry(models.Model): name = mod

Solution 1:

Firstly you appear to have some special quote characters around your date string, remove them:

this_mycustomdate = this_mycustomdate.strip('“”') # Note these are not the normal double quotes

Next convert your string into a datetime instance:

from datetime import datetime

this_mycustomdate = datetime.strptime(this_mycustomdate, "%d/%m/%Y %I:%M %p") # I have considered the format of the date as DD/MM/YYYY

After this you should be good to go.


Post a Comment for "ValidationError With Datatime Field In Django"