I have mixed models with admin in my example. Sorry.

It should be like this:

### models.py
[...]
class JobForm(ModelForm):
    def __init__(self, *args, **kwargs):
        super(JobForm,self).__init__(*args,**kwargs)
        self.fields['price'].localize = True
...
[...]
###

### admin.py

class JobAdmin(admin.ModelAdmin):
     form = JobForm
...
[..]
###

On 5. Júl, 15:48 h., saboter <[email protected]> wrote:
> Hello,
>
> i have the same problem, the decimal field input is not localized by
> default in admin. (Works in changelist.)  So it shows and accepts only
> dot as decimal separator.
>
> It looks that admin doesnt set localize parameter in Field class init.
> (Its False by default.)
> I didnt found a ticket exactly for the "decimal issue", but this 
> onehttp://code.djangoproject.com/ticket/13560 looks relevant to the
> problem.
>
> Thank you very much for posting your workaround.
>
> I've used it this way:
>
> ### models.py
> [...]
> class JobForm(ModelForm):
>     def __init__(self, *args, **kwargs):
>         super(JobForm,self).__init__(*args,**kwargs)
>         self.fields['price'].localize = True
>
> class JobAdmin(admin.ModelAdmin):
>     form = JobForm
>     ...
> [...]
> ###
>
> Regards,
>
> Martin
>
> On 4. Júl, 13:39 h., Simon Westphahl <[email protected]> wrote:
>
>
>
> > I figured out a way to get it working.
>
> > ### models.py
> > [...]
> > class DecTest(models.Model):
> >     dec = models.DecimalField(max_digits=8, decimal_places=2)
>
> > class LocalDecForm(forms.ModelForm):
> >     dec = forms.DecimalField(max_digits=8, decimal_places=2,
> > localize=True)
> >     class Meta:
> >         model = DecTest
>
> > class DecAdmin(admin.ModelAdmin):
> >     form = LocalDecForm
> >     list_display = ('dec',)
> > [...]
> > ###
>
> > But is this realy the way it's meant to work? A "DateTimeField" is
> > localized by default ...
>
> > On 4 Jul., 11:03, Simon Westphahl <[email protected]> wrote:
>
> > > For clarification: The output in the admin list view is properly
> > > localized. Only the input doesn't work.
> > > I'm using Django 1.2.1 and a almost vanilla Django project only with
> > > this one test app installed.
>
> > > On 3 Jul., 22:07, Simon Westphahl <[email protected]> wrote:
>
> > > > Hi,
>
> > > > I tried to implement a localized "DecimalField" but it doesn't seem to
> > > > work. When entering a decimal number with a German decimal seperator
> > > > ( , ) the admin interface tells me to "Enter a number". Is there some
> > > > setting/middleware/etc. I overlooked?
>
> > > > My "settings.py" and test model look something like this:
>
> > > > ### settings.py ###
> > > > [...]
> > > > LANGUAGE_CODE = 'de'
> > > > USE_I18N = True
> > > > USE_L10N = True
> > > > [...]
> > > > ###
>
> > > > ### models.py ###
> > > > from django.contrib import admin
> > > > from django.db import models
>
> > > > class DecTest(models.Model):
> > > >     dec = models.DecimalField(max_digits=8, decimal_places=2)
>
> > > > admin.site.register(DecTest)
> > > > ###
>
> > > > Thanks in advance!
>
> > > > Regards
> > > > Simon

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" 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 this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to