Opened 17 years ago
Closed 15 years ago
#6231 closed (fixed)
SelectDateWidget: field order as a result of DATE_FORMAT
Reported by: | Bernd Schlapsi | Owned by: | Marc Garcia |
---|---|---|---|
Component: | Internationalization | Version: | dev |
Severity: | Keywords: | i18n-rf | |
Cc: | andy@… | Triage Stage: | Fixed on a branch |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The SelectDateWidget had a fix output in the format: MONTH/DAY/YEAR.
It would be nice, if the format could follow the DATE_FORMAT in settings.py and take care of the correct order.
Attachments (4)
Change History (21)
comment:1 by , 17 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 17 years ago
comment:3 by , 17 years ago
This is the source-code for the render function of SelectDateWidget from trunk/django/newforms/extras/widgets.py
def render(self, name, value, attrs=None): try: value = datetime.date(*map(int, value.split('-'))) year_val, month_val, day_val = value.year, value.month, value.day except (AttributeError, TypeError, ValueError): year_val = month_val = day_val = None output = [] month_choices = MONTHS.items() month_choices.sort() select_html = Select(choices=month_choices).render(self.month_field % name, month_val) output.append(select_html) day_choices = [(i, i) for i in range(1, 32)] select_html = Select(choices=day_choices).render(self.day_field % name, day_val) output.append(select_html) year_choices = [(i, i) for i in self.years] select_html = Select(choices=year_choices).render(self.year_field % name, year_val) output.append(select_html) return mark_safe(u'\n'.join(output))
If I read/understand this function correct, the SelectDateWidget returns MONTH/DAY/YEAR format
comment:4 by , 17 years ago
I see, you mean the order not the literally "slash".
DATE_FORMAT Can take many variables that do not apply in select boxes. Consider this case: "%A, %B %Y". How do you render this?
comment:5 by , 17 years ago
I know that DATE_FORMAT can take a lot of variables. I don't know a good solution yet. I am new to python and django, otherwise I would have tried to write a patch. But I think it's important to give this widget a bit of flexibility. In Europe we don't use the date format MONTH/DAY/YEAR.
Could it be a (good) solution to check the usual date formats? If none of them would be submitted, the widget could use a default date format. What do you think?
comment:6 by , 17 years ago
The patch above addresses this issue and also add a TimeSelectWidget.
It include regression tests.
David.
comment:7 by , 17 years ago
Has patch: | set |
---|
comment:8 by , 16 years ago
Keywords: | i18n-rf added |
---|
comment:9 by , 16 years ago
Component: | django.newforms → Internationalization |
---|---|
milestone: | → post-1.0 |
by , 16 years ago
Attachment: | ticket_6231_v2.patch added |
---|
New patch-version that works with current django-version (replaced newforms with forms)
comment:10 by , 16 years ago
Cc: | added |
---|
comment:12 by , 15 years ago
Please don't integrate patches like this; it makes things *really* hard to figure out. One patch per ticket.
by , 15 years ago
Attachment: | ticket_6231_v4.patch added |
---|
New patch-version that works with current django-version (after Changeset [10585])
comment:13 by , 15 years ago
Owner: | changed from | to
---|
comment:14 by , 15 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:15 by , 15 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
Last commit shouldn't close the ticket, but Ref it. Reopening.
comment:16 by , 15 years ago
Triage Stage: | Accepted → Fixed on a branch |
---|
comment:17 by , 15 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
(In [11964]) Fixed #7980 - Improved i18n framework to support locale aware formatting (dates and numbers) and form processing.
Thanks to Marc Garcia for working on this during his Google Summer of Code 2009!
Additionally fixes #1061, #2203, #3940, #5526, #6449, #6231, #6693, #6783, #9366 and #10891.
Actually SelectDateWidget isn't returning MONTH/DAY/YEAR format.