Opened 16 years ago

Closed 16 years ago

Last modified 16 years ago

#10220 closed (worksforme)

the admin site can not handle the DateField.

Reported by: duns Owned by: nobody
Component: Uncategorized Version: 1.0
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

class WInfo(models.Model):
    city = models.CharField(max_length=1, default='A')
    w_date = models.DateField()
    
    def __unicode__(self):
        return str(self.id)

In the admin site, I fail to add a record. After I modify SplitDateTimeWidget.decompress, it's OK.

"C:\Python25\lib\site-packages\django\forms\widgets.py"

class SplitDateTimeWidget(MultiWidget):
    ...
    def decompress(self, value):
        if value:
            #return [value.date(), value.time().replace(microsecond=0)]
            if type(value) == 'datetime':
                return [value.day(), value.time().replace(microsecond=0)]
            if type(value) == 'date':
                return [value, None]            
        return [None, None]

Change History (2)

comment:1 by Ramiro Morales, 16 years ago

Resolution: worksforme
Status: newclosed

I implemented your example using Django r9820 and sqlite3 and I could add a WInfo instance without problems (by entering a valid value for the w_date field).

Closing this ticket, reopen if you are willing to provide more details, for example, exact Django SVN revision or release, database backend in use (and the traceback, if any, you are getting when you say "In the admin site, I fail to add a record.") or better yet, post to the django-user mailing list.

comment:2 by (none), 16 years ago

milestone: post-1.0

Milestone post-1.0 deleted

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