Re: [Django] #18519: DateField ignores DATE_INPUT_FORMATS (because get_format ignores it)

2012-07-01 Thread Django
#18519: DateField ignores DATE_INPUT_FORMATS (because get_format ignores it)
-+-
 Reporter:  marcin.tustin@…  |Owner:  nobody
 Type:  Bug  |   Status:  closed
Component:  Forms|  Version:  1.4
 Severity:  Normal   |   Resolution:  invalid
 Keywords:  DateField,   | Triage Stage:
  django.utils.formats   |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  1|UI/UX:  0
-+-
Changes (by kmtracey):

 * status:  new => closed
 * needs_better_patch:   => 0
 * resolution:   => invalid
 * needs_tests:   => 0
 * needs_docs:   => 0


Comment:

 What is your `USE_L10N` setting? As noted in the
 [https://docs.djangoproject.com/en/1.4/ref/settings/#date-input-formats
 doc for `DATE_INPUT_FORMATS`] it is only used when `USE_L10N` is `False`.
 I suspect in your case it is `True` and the values being used are the
 
[https://github.com/django/django/blob/master/django/conf/locale/en/formats.py#L18
 locale-specific ones] instead.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



[Django] #18519: DateField ignores DATE_INPUT_FORMATS (because get_format ignores it)

2012-06-26 Thread Django
#18519: DateField ignores DATE_INPUT_FORMATS (because get_format ignores it)
-+-
 Reporter:   |  Owner:  nobody
  marcin.tustin@…| Status:  new
 Type:  Bug  |Version:  1.4
Component:  Forms|   Keywords:  DateField, django.utils.formats
 Severity:  Normal   |  Has patch:  0
 Triage Stage:  Unreviewed   |  UI/UX:  0
Easy pickings:  1|
-+-
 DateFields in forms do not have their behaviour altered by the setting
 DATE_INPUT_FORMATS.

 This happens because django.utils.get_format ignores it.

 Here is a transcript of a debug session demonstrating that:


 {{{
 In [14]: df.to_python('13-03-1978')
 ---
 ValidationError   Traceback (most recent call
 last)
 /home/marcintustin/webapps/django/oneclickcosvirt/lib/python2.7/site-
 packages/django/core/management/commands/shell.pyc in ()
 > 1 df.to_python('13-03-1978')

 /home/marcintustin/webapps/django/oneclickcosvirt/lib/python2.7/site-
 packages/django/forms/fields.pyc in to_python(self, value)
 377 if isinstance(value, datetime.date):
 378 return value
 --> 379 return super(DateField, self).to_python(value)
 380
 381 def strptime(self, value, format):

 /home/marcintustin/webapps/django/oneclickcosvirt/lib/python2.7/site-
 packages/django/forms/fields.pyc in to_python(self, value)
 354 except ValueError:
 355 continue
 --> 356 raise ValidationError(self.error_messages['invalid'])
 357
 358 def strptime(self, value, format):

 ValidationError: [u'Enter a valid date.']

 In [15]: import pdb; pdb.pm()
 > /home/marcintustin/webapps/django/oneclickcosvirt/lib/python2.7/site-
 packages/django/forms/fields.py(356)to_python()
 -> raise ValidationError(self.error_messages['invalid'])
 (Pdb) l
 351 usecs = int(usecs_str[:6].ljust(6,
 '0'))
 352 dt =
 datetime.datetime.strptime(datetime_str, format[:-3])
 353 return dt.replace(microsecond=usecs)
 354 except ValueError:
 355 continue
 356  -> raise ValidationError(self.error_messages['invalid'])
 357
 358 def strptime(self, value, format):
 359 raise NotImplementedError('Subclasses must define this
 method.')
 360
 361 class DateField(BaseTemporalField):
 (Pdb) format
 '%m/%d/%y'
 (Pdb) self.input_formats
 
 (Pdb) list(self.input_formats)
 *** Error in argument: '(self.input_formats)'
 (Pdb) self.input_formats
 
 (Pdb) tuple(self.input_formats)
 ('%Y-%m-%d', '%m/%d/%Y', '%m/%d/%y')
 (Pdb) self
 
 (Pdb) formats
 
 (Pdb) formats.get_format_lazy('DATE_INPUT_FORMATS')
 
 (Pdb) tuple(formats.get_format_lazy('DATE_INPUT_FORMATS'))
 ('%Y-%m-%d', '%m/%d/%Y', '%m/%d/%y')
 (Pdb) from django.conf import settings
 (Pdb) settings.DATE_INPUT_FORMATS
 ('%d-%m-%y', '%d-%b-%Y', '%d-%B-%y', '%d-%m-%Y', '%d-%b-%y', '%d-%B-%Y',
 '%d/%m/%y', '%d/%b/%Y', '%d/%B/%y', '%d/%m/%Y', '%d/%b/%y', '%d/%B/%Y',
 '%d %m %y', '%d %b %Y', '%d %B %y', '%d %m %Y', '%d %b %y', '%d %B %Y',
 '%Y-%m-%d', '%m/%d/%Y', '%m/%d/%y', '%b %d %Y', '%b %d, %Y', '%d %b %Y',
 '%d %b, %Y', '%B %d %Y', '%B %d, %Y', '%d %B %Y', '%d %B, %Y', '%x')
 (Pdb) getattr(settings, 'DATE_INPUT_FORMATS')
 ('%d-%m-%y', '%d-%b-%Y', '%d-%B-%y', '%d-%m-%Y', '%d-%b-%y', '%d-%B-%Y',
 '%d/%m/%y', '%d/%b/%Y', '%d/%B/%y', '%d/%m/%Y', '%d/%b/%y', '%d/%B/%Y',
 '%d %m %y', '%d %b %Y', '%d %B %y', '%d %m %Y', '%d %b %y', '%d %B %Y',
 '%Y-%m-%d', '%m/%d/%Y', '%m/%d/%y', '%b %d %Y', '%b %d, %Y', '%d %b %Y',
 '%d %b, %Y', '%B %d %Y', '%B %d, %Y', '%d %B %Y', '%d %B, %Y', '%x')
 (Pdb) formats.get_format('DATE_INPUT_FORMATS')
 ('%Y-%m-%d', '%m/%d/%Y', '%m/%d/%y')
 (Pdb)
 }}}

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.