#31471: DateTimeField is returned as str instead of as datetime object, when
using
reverse lookup
------------------------------------+--------------------------------------
Reporter: Fonville | Owner: (none)
Type: Bug | Status: new
Component: Uncategorized | Version: 3.0
Severity: Normal | Resolution:
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
------------------------------------+--------------------------------------
Changes (by ovkulkarni):
* owner: ovkulkarni => (none)
* status: assigned => new
Comment:
I was unable to reproduce this bug using Django 3.0.5, Python 3.8.0, and a
SQLite database. My models and REPL output are shown below:
models.py
{{{
from django.db import models
class Test(models.Model):
time_stamp = models.DateTimeField(auto_now=True)
class RelationTest(models.Model):
test_field = models.OneToOneField(Test, on_delete=models.CASCADE,
primary_key=True)
}}}
REPL:
{{{
$ ./manage.py shell
Python 3.8.0 (v3.8.0:fa919fdf25, Oct 14 2019, 10:23:27)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from app.models import *
>>> r = RelationTest.objects.get(test_field=1)
>>> r.test_field.time_stamp
datetime.datetime(2020, 4, 16, 19, 48, 44, 277170, tzinfo=<UTC>)
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/31471#comment:2>
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.4f8c0042a3d7af59fb19e85f1dca515d%40djangoproject.com.