#31471: update_or_create object returns either an unparsed field (like a str) or
datetime for DateTimeField, depending on whether object is saved or not.
------------------------------------+--------------------------------------
Reporter: Fonville | Owner: (none)
Type: Bug | Status: closed
Component: Uncategorized | Version: 3.0
Severity: Normal | Resolution: worksforme
Keywords: datetime, OneToOne | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------------+--------------------------------------
Comment (by Fonville):
Ok, I found the culprit, I was entering the datetime as a str into the
model with the DateTimeField using a update_or_create() method as a kwarg.
Depending on whether the update_or_create had triggered a save (and thus
parsing) of the field, the field was either a string or a datetime.
I am not sure what your take is on things, but imho the nondeterministic
behaviour of update_or_create() is in my opinion not expected by a
developer.
I would expect even if the object is not updated in the database, the
field to still be parsed into a datetime in the object returned by the
update_or_create() method.
--
Ticket URL: <https://code.djangoproject.com/ticket/31471#comment:5>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/067.f9c2062fdf804c4405dfebbdd900c840%40djangoproject.com.