#18769: Despite selected language, Forms still rely on LANGUAGE_CODE to format
datetime (demo included)
-------------------------------------+-------------------------------------
     Reporter:  houmie               |                    Owner:  nobody
         Type:  Bug                  |                   Status:  closed
    Component:                       |                  Version:  1.4
  Internationalization               |               Resolution:  invalid
     Severity:  Normal               |             Triage Stage:
     Keywords:  formats, i18n, l10n  |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by kmtracey):

 * status:  new => closed
 * resolution:   => invalid


Comment:

 The form you are using hasn't specified to localize the fields. The
 forms.py file in the sandbox project has:

 {{{
 #!python
 from django.forms.models import ModelForm
 from Sandbox_App.models import Company

 class CompanyForm(ModelForm):
     def date_callback(self, field, **kwargs) :
         return field.date(localize=True, **kwargs)
     def time_callback(self, field, **kwargs) :
         return field.time(localize=True, **kwargs)

     class Meta:
         model = Company
 }}}

 I gather it is expected that these callback functions will turn on
 localization for the fields, but I do not know where the idea for defining
 these callbacks came from. Django model forms do not call these functions,
 so they have no effect. Changing that forrms.py file to:

 {{{
 #!python
 from django import forms
 from Sandbox_App.models import Company

 class CompanyForm(forms.ModelForm):
     date = forms.DateField(localize=True)
     time = forms.TimeField(localize=True)

     class Meta:
         model = Company
 }}}

 results in the form on initial display being localized as per the chosen
 language.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/18769#comment:2>
Django <https://code.djangoproject.com/>
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to