Coverage for /home/tribaal/workspace/django-shop/shop/admin/mixins: 27.78%

# Coverage for /home/tribaal/workspace/django-shop/shop/admin/mixins : 27.78%

## 12 statements 5 run 7 missing 0 excluded 0 partial

Hot-keys on this page

r m x p toggle line displays

j k next/prev highlighted chunk

0 (zero) top of page

1 (one) first highlighted chunk

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | #-*- coding: utf-8 -*- from django import forms class LocalizeDecimalFieldsForm(forms.ModelForm): def __new__(cls, *args, **kwargs): new_class = super(LocalizeDecimalFieldsForm, cls).__new__(cls) if hasattr(new_class, 'base_fields'): for field in new_class.base_fields.values(): if isinstance(field, (forms.DecimalField, forms.FloatField)): field.localize = True field.widget.is_localized = True return new_class class LocalizeDecimalFieldsMixin(object): ''' To be used as a mixin for classes derived from admin.ModelAdmin, admin.TabularInline, etc. which localizes the input fields for models of type DecimalField in the admin interface. If your class derived from ModelAdmin wants to override the form attribute, make sure that this form is derived from LocalizeDecimalFieldsForm and not from forms.ModelForm. ''' form = LocalizeDecimalFieldsForm