1 | from django import forms
|
---|
2 |
|
---|
3 | class FieldWithClassWidget(forms.Field):
|
---|
4 |
|
---|
5 | def __init__(self,*args,**kwargs):
|
---|
6 | super(FieldWithClassWidget,self).__init__(*args,**kwargs)
|
---|
7 |
|
---|
8 | # Accept other required kwargs...
|
---|
9 |
|
---|
10 | self.widget = kwargs['widget'] if 'widget' in kwargs else forms.Textarea
|
---|
11 |
|
---|
12 | class FieldWithObjectWidget(forms.Field):
|
---|
13 |
|
---|
14 | def __init__(self,*args,**kwargs):
|
---|
15 | super(FieldWithObjectWidget,self).__init__(*args,**kwargs)
|
---|
16 |
|
---|
17 | # Accept other required kwargs...
|
---|
18 |
|
---|
19 | self.widget = kwargs['widget'] if 'widget' in kwargs else forms.Textarea()
|
---|
20 |
|
---|
21 | class FormWithClassWidget(forms.Form):
|
---|
22 |
|
---|
23 | field = FieldWithClassWidget()
|
---|
24 |
|
---|
25 | class FormWithObjectWidget(forms.Form):
|
---|
26 |
|
---|
27 | field = FieldWithObjectWidget()
|
---|