Re: [Django] #27364: DATE_INPUT_FORMATS is not working

2016-10-19 Thread Django
#27364: DATE_INPUT_FORMATS is not working
-+-
 Reporter:  Alex |Owner:  nobody
 Type:  Bug  |   Status:  closed
Component:  Database layer   |  Version:  1.10
  (models, ORM)  |
 Severity:  Normal   |   Resolution:  invalid
 Keywords:  date | Triage Stage:
 |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Tim Graham):

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


Comment:

 My understanding is that only form fields (rather than model fields)
 handle those formats (e.g.
 
[https://github.com/django/django/blob/90c3b11e873a326219a68c14a3b5dca0181e7b3c/django/forms/fields.py#L409
 DateField]).

--
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 unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.49538154591618ccf0a85f2cb556ed52%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


[Django] #27364: DATE_INPUT_FORMATS is not working

2016-10-19 Thread Django
#27364: DATE_INPUT_FORMATS is not working
--+
 Reporter:  Alex  |  Owner:  nobody
 Type:  Bug   | Status:  new
Component:  Database layer (models, ORM)  |Version:  1.10
 Severity:  Normal|   Keywords:  date
 Triage Stage:  Unreviewed|  Has patch:  0
Easy pickings:  0 |  UI/UX:  0
--+
 Per the Django Docs, in settings.py if I set USE_L10N to false, I should
 be able to override the supported date formats. My settings.py has the
 following:



 {{{
 LANGUAGE_CODE = 'en-us'

 TIME_ZONE = 'UTC'

 USE_I18N = False

 USE_L10N = False

 USE_TZ = False

 DATE_INPUT_FORMATS = [
 '%Y-%m-%d', '%m/%d/%Y', '%m/%d/%y', # '2006-10-25', '10/25/2006',
 '10/25/06'
 '%b %d %Y', '%b %d, %Y',# 'Oct 25 2006', 'Oct 25, 2006'
 '%d %b %Y', '%d %b, %Y',# '25 Oct 2006', '25 Oct, 2006'
 '%B %d %Y', '%B %d, %Y',# 'October 25 2006', 'October 25,
 2006'
 '%d %B %Y', '%d %B, %Y',# '25 October 2006', '25 October,
 2006'
 ]
 }}}

 I have a model that looks like the following:

 {{{
 class DateTest(models.Model):
 date = models.DateField(blank=True, null=True)
 }}}

 When I run the following command, i get an error:


 {{{
 >>> DateTest.objects.create(date='09/01/2016')
 Traceback (most recent call last):
   File "", line 1, in 
   File "/Users/abeach/Workspace/orchard/env/lib/python3.5/site-
 packages/django/db/models/manager.py", line 85, in manager_method
 return getattr(self.get_queryset(), name)(*args, **kwargs)
   File "/Users/abeach/Workspace/orchard/env/lib/python3.5/site-
 packages/django/db/models/query.py", line 399, in create
 obj.save(force_insert=True, using=self.db)
   File "/Users/abeach/Workspace/orchard/env/lib/python3.5/site-
 packages/django/db/models/base.py", line 796, in save
 force_update=force_update, update_fields=update_fields)
   File "/Users/abeach/Workspace/orchard/env/lib/python3.5/site-
 packages/django/db/models/base.py", line 824, in save_base
 updated = self._save_table(raw, cls, force_insert, force_update,
 using, update_fields)
   File "/Users/abeach/Workspace/orchard/env/lib/python3.5/site-
 packages/django/db/models/base.py", line 908, in _save_table
 result = self._do_insert(cls._base_manager, using, fields, update_pk,
 raw)
   File "/Users/abeach/Workspace/orchard/env/lib/python3.5/site-
 packages/django/db/models/base.py", line 947, in _do_insert
 using=using, raw=raw)
   File "/Users/abeach/Workspace/orchard/env/lib/python3.5/site-
 packages/django/db/models/manager.py", line 85, in manager_method
 return getattr(self.get_queryset(), name)(*args, **kwargs)
   File "/Users/abeach/Workspace/orchard/env/lib/python3.5/site-
 packages/django/db/models/query.py", line 1045, in _insert
 return query.get_compiler(using=using).execute_sql(return_id)
   File "/Users/abeach/Workspace/orchard/env/lib/python3.5/site-
 packages/django/db/models/sql/compiler.py", line 1053, in execute_sql
 for sql, params in self.as_sql():
   File "/Users/abeach/Workspace/orchard/env/lib/python3.5/site-
 packages/django/db/models/sql/compiler.py", line 1006, in as_sql
 for obj in self.query.objs
   File "/Users/abeach/Workspace/orchard/env/lib/python3.5/site-
 packages/django/db/models/sql/compiler.py", line 1006, in 
 for obj in self.query.objs
   File "/Users/abeach/Workspace/orchard/env/lib/python3.5/site-
 packages/django/db/models/sql/compiler.py", line 1005, in 
 [self.prepare_value(field, self.pre_save_val(field, obj)) for field in
 fields]
   File "/Users/abeach/Workspace/orchard/env/lib/python3.5/site-
 packages/django/db/models/sql/compiler.py", line 945, in prepare_value
 value = field.get_db_prep_save(value, connection=self.connection)
   File "/Users/abeach/Workspace/orchard/env/lib/python3.5/site-
 packages/django/db/models/fields/__init__.py", line 755, in
 get_db_prep_save
 prepared=False)
   File "/Users/abeach/Workspace/orchard/env/lib/python3.5/site-
 packages/django/db/models/fields/__init__.py", line 1280, in
 get_db_prep_value
 value = self.get_prep_value(value)
   File "/Users/abeach/Workspace/orchard/env/lib/python3.5/site-
 packages/django/db/models/fields/__init__.py", line 1275, in
 get_prep_value
 return self.to_python(value)
   File "/Users/abeach/Workspace/orchard/env/lib/python3.5/site-
 packages/django/db/models/fields/__init__.py", line 1250, in to_python
 params={'value': value},
 django.core.exceptions.ValidationError: ["'09/01/2016' value has an
 invalid date format. It must be in -MM-DD format."]

 }}}

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

-- 
You received