Code

Opened 4 years ago

Closed 4 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: UI/UX:

Description (last modified by Alex)

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)

Attachments (0)

Change History (7)

comment:1 Changed 4 years ago by mischko

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Version changed from 1.2 to 1.1

comment:2 Changed 4 years ago by mischko

  • Version changed from 1.1 to 1.2

Tested on 1.1.0 and 1.2.3.

comment:3 Changed 4 years ago by Alex

  • Description modified (diff)

Added formatting.

comment:4 Changed 4 years ago by pandres

  • Summary changed from DateField is not coming in as Python's datetime.date object to DateField is not coming in as Python's datetime.date object (in Oracle)

comment:5 Changed 4 years ago by ikelly

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 Changed 4 years ago by ikelly

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

comment:7 Changed 4 years ago by ikelly

  • Resolution set to duplicate
  • Status changed from new to closed

Dup of #10970

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.