Reputation: 23
My code is
Message.objects.filter(id=message_id).update(read_at='Null')
getting this error
ValidationError: [u'Enter a valid date/time in YYYY-MM-DD HH:MM[:ss[.uuuuuu]] format.']
and the model is
read_at = models.DateTimeField(_("read at"), null=True, blank=True)
Is there any way to update datetime to null? Please help.
Upvotes: 2
Views: 3960
Reputation: 37364
Django update calls are written in Python rather than SQL - use None
instead:
Message.objects.filter(id=message_id).update(read_at=None)
Upvotes: 3