Opened 13 years ago

Last modified 13 years ago

#14626 closed

DateField is not coming in as Python's datetime.date object — at Version 3

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 (3)

comment:1 by mischko, 13 years ago

Version: 1.21.1

comment:2 by mischko, 13 years ago

Version: 1.11.2

Tested on 1.1.0 and 1.2.3.

comment:3 by Alex Gaynor, 13 years ago

Description: modified (diff)

Added formatting.

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