Opened 12 years ago

Closed 12 years ago

#5069 closed (wontfix)

newforms cannot initial SelectDateWidget 's value

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


form with SelectDateWidget

class Person(newforms.form):
    birthday = forms.DateField( widget=utils.widgets.SelectDateWidget())

that 's ok

form = Person(request.POST)

but cannot

form = Person(initial = request.POST)

Change History (2)

comment:1 Changed 12 years ago by Adrian Holovaty

What error do you get when you try this?

comment:2 Changed 12 years ago by flother

Resolution: wontfix
Status: newclosed

The problem is that:

form = Person(initial=request.POST)

doesn't pre-populate the rendered SelectDateWidget; it's left with defaults (1st of January of the earliest year in the list) instead, because the POST data is in a different format to that which initial is expected to be, and isn't passed to the widget. There are inherent differences between initial data and bound data; the correct way to do pass in POST data is form = Person(request.POST), as you mention.

I'm closing this as wontfix, but if there's any good reason you want to pass POST data in as the inital data, reopen the ticket.

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