Code

Opened 5 years ago

Closed 5 years ago

Last modified 5 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: UI/UX:

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]

Attachments (0)

Change History (2)

comment:1 Changed 5 years ago by ramiro

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to worksforme
  • Status changed from new to closed

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 Changed 5 years ago by anonymous

  • milestone post-1.0 deleted

Milestone post-1.0 deleted

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.