Opened 14 years ago

Closed 14 years ago

#14626 closed (duplicate)

DateField with auto_now=True is not coming in as Python's datetime.date object in Python 2.4 / 2.5

Reported by: mischko Owned by: nobody
Component: Database layer (models, ORM) Version: 1.2
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Alex Gaynor)

Oracle backend with cx_Oracle 5.0.4
Python 2.4.3
Oracle 11

class scott_test1(models.Model):
    graphic_id = models.IntegerField()
    graphic_desc = models.CharField(max_length=30)
    curves = models.TextField()
    graphic_type = models.CharField(max_length=4)
    df = models.DateField(null=True, auto_now = True) # datetime.date
    dtf = models.DateTimeField(null=True, auto_now = True) # datetime.datetime
    tf = models.TimeField(null=True, auto_now =True) # datetime.time

foo=scott_test1(graphic_id=2,graphic_desc="here is some text", curves= ", ".join([str(x * 3.1514) for x in xrange(1000)]), graphic_type="none")

foo.save()

According to the docs at http://docs.djangoproject.com/en/dev/ref/models/fields/#datefield, foo.df should be a datetime.date object, not datetime.datetime:

In [7]: foo.df
Out[7]: datetime.datetime(2010, 11, 5, 10, 13, 3, 744903)

In [8]: foo.dtf
Out[8]: datetime.datetime(2010, 11, 5, 10, 13, 3, 745076)

In [9]: foo.tf
Out[9]: datetime.time(10, 13, 3, 745130)

Change History (7)

comment:1 by mischko, 14 years ago

Version: 1.21.1

comment:2 by mischko, 14 years ago

Version: 1.11.2

Tested on 1.1.0 and 1.2.3.

comment:3 by Alex Gaynor, 14 years ago

Description: modified (diff)

Added formatting.

comment:4 by pandres, 14 years ago

Summary: DateField is not coming in as Python's datetime.date objectDateField is not coming in as Python's datetime.date object (in Oracle)

comment:5 by Erin Kelly, 14 years ago

I think this may actually be an auto_now bug. The test_datefield_auto_now_add test in the datatypes suite of the 1.2.X branch is failing for both oracle and sqlite3 backends when running Python 2.5, but not with Python 2.7. The test_date_type test in the same suite that tests for this bug in the more general case is not failing at all.

comment:6 by Erin Kelly, 14 years ago

Summary: DateField is not coming in as Python's datetime.date object (in Oracle)DateField with auto_now=True is not coming in as Python's datetime.date object in Python 2.4 / 2.5

comment:7 by Erin Kelly, 14 years ago

Resolution: duplicate
Status: newclosed

Dup of #10970

Note: See TracTickets for help on using tickets.
Back to Top