Using the Django framework (1.3.1) with Mongoengine.
When you try to save a published field (due date), it is issued using
ValidationError (cannot parse the date "2013-12-31": ['DueDate'])
However, when saving the date using datetime.datetime.now() it works fine. After searching for examples, I have no options.
Related parts of my code (with a regular HTML form using a text input tag):
views.py
goal.DueDate = request.POST['duedate'] goal.save()
models.py
class Goal(Document): DueDate = DateTimeField() last_update = DateTimeField(required=True)
Any idea?
Refresh (can't answer yet):
Ok, found a solution. Typing seems to have given new ideas.
goal.DueDate = datetime.datetime.strptime (request.POST ['duedate'], '% Y-% m-% d')
source share