Thanks Carlos, Yes I could utilize the format field as you suggested and it would work fine but this is bad.

I will have customers in USA and also in Europe. Both would run from the same server, hence I need eventually enable the localization according to the user's locality.

|MIDDLEWARE_CLASSES=  (
    ...
    'django.middleware.locale.LocaleMiddleware',
)
|


So from then on the Americans can see their date in their format and Europeans in theirs. If I hardcoded the format like this though, this would break it for one or the other group. Django has to do it through the culture automatically.

I don't understand, it works for templates, inputformat for forms works as well, only the form-output is not working. So weird...I really am curios how the American Django users have setup their date fields in the ModelForm. :) I think I have to wait til later today so they wake up and see the emails. :))

Thank you,
Houman


On 13/08/12 14:46, Carlos Palol wrote:
Try configuring your form field directly, like this:

class CallsForm(ModelForm):
    contact_date = forms.DateField(
        localize=True,
        input_formats=['%m/%d/%Y'],
        widget=forms.DateInput(attrs={
            'placeholder'='Format is m/d/yyyy...',
        })
    )

    class Meta:
        model = Conversation

This combination of attributes input_formats and localize should make this field to use the m/d/y format for forms (always), while printing the value in the localized way (Aug. 31, 2012).

Cheers


On Monday, 13 August 2012 14:47:57 UTC+2, Houmie wrote:

    Thanks Melvyn,

    I have tried this:

    def contact_date_callback(self, field, **kwargs) :
             return field.contact_date(localize=True, **kwargs)

    But the date still shows as 2012-08-13

    note, that Aptana Studio 3.0 complained that I put `self` first.

    Nonetheless neither version works.

    Any other idea? :(


    On 13/08/12 13:20, Melvyn Sopacua wrote:
    > def formfield_callback(field, **kwargs) :
    >         return field.formfield(localize=True, **kwargs)

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

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

Reply via email to