Skip to content

Commit 09931c9

Browse files
author
Lukas Vinclav
committed
inherit media files from parent class
1 parent 73b1fbf commit 09931c9

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

admin_numeric_filter/forms.py

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
from django import forms
2+
from django.forms import Media
23
from django.utils.translation import ugettext_lazy as _
34

45

6+
NUMERIC_FILTER_CSS = 'css/admin-numeric-filter.css'
7+
8+
59
class SingleNumericForm(forms.Form):
610
def __init__(self, *args, **kwargs):
711
name = kwargs.pop('name')
812
super().__init__(*args, **kwargs)
913

10-
self.fields[name] = forms.FloatField(label='', required=False,
11-
widget=forms.NumberInput(attrs={'placeholder': _('Value')}))
14+
self.fields[name] = forms.FloatField(label='', required=False,
15+
widget=forms.NumberInput(attrs={'placeholder': _('Value')}))
1216

13-
class Media:
14-
css = {
15-
'all': (
16-
'css/admin-numeric-filter.css',
17-
)
18-
}
17+
@property
18+
def media(self):
19+
return super().media + Media(css=[self.NUMERIC_FILTER_CSS])
1920

2021

2122
class RangeNumericForm(forms.Form):
@@ -25,17 +26,14 @@ def __init__(self, *args, **kwargs):
2526
self.name = kwargs.pop('name')
2627
super().__init__(*args, **kwargs)
2728

28-
self.fields[self.name + '_from'] = forms.FloatField(label='', required=False,
29+
self.fields[self.name + '_from'] = forms.FloatField(label='', required=False,
2930
widget=forms.NumberInput(attrs={'placeholder': _('From')}))
30-
self.fields[self.name + '_to'] = forms.FloatField(label='', required=False,
31+
self.fields[self.name + '_to'] = forms.FloatField(label='', required=False,
3132
widget=forms.NumberInput(attrs={'placeholder': _('To')}))
3233

33-
class Media:
34-
css = {
35-
'all': (
36-
'css/admin-numeric-filter.css',
37-
)
38-
}
34+
@property
35+
def media(self):
36+
return super().media + Media(css=[self.NUMERIC_FILTER_CSS])
3937

4038

4139
class SliderNumericForm(RangeNumericForm):

0 commit comments

Comments
 (0)