From f2b0f8ea0fc5849801a2aeb71f2db106e5655aea Mon Sep 17 00:00:00 2001 From: Ramiro Morales Date: Sat, 5 Feb 2011 18:16:27 +0000 Subject: [PATCH] Fixed #15226 - Made SelectDateWidget render the label tag associated with the correct dropdown sub-widget when USE_L10N is active and non-English locale is in use. git-svn-id: http://code.djangoproject.com/svn/django/trunk@15427 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/forms/extras/widgets.py | 44 ++++++++++++++++------ tests/regressiontests/forms/tests/extra.py | 9 +++++ 2 files changed, 41 insertions(+), 12 deletions(-) diff --git a/django/forms/extras/widgets.py b/django/forms/extras/widgets.py index 0cd88b8170..e8bacf2b1e 100644 --- a/django/forms/extras/widgets.py +++ b/django/forms/extras/widgets.py @@ -17,6 +17,26 @@ __all__ = ('SelectDateWidget',) RE_DATE = re.compile(r'(\d{4})-(\d\d?)-(\d\d?)$') +def _parse_date_fmt(): + fmt = get_format('DATE_FORMAT') + escaped = False + output = [] + for char in fmt: + if escaped: + escaped = False + elif char == '\\': + escaped = True + elif char in 'Yy': + output.append('year') + #if not self.first_select: self.first_select = 'year' + elif char in 'bEFMmNn': + output.append('month') + #if not self.first_select: self.first_select = 'month' + elif char in 'dj': + output.append('day') + #if not self.first_select: self.first_select = 'day' + return output + class SelectDateWidget(Widget): """ A Widget that splits date input into three