1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | class NoInput(forms.Widget):
def render(self, name, value, attrs=None):
return mark_safe(value)
class StaticField(forms.Field):
widget = NoInput
def clean(self, value):
return
# Example usage
#class OnlyTextForm(forms.ModelForm):
#
# points = StaticField(label=_('Points'))
# reviewer = StaticField(label=_('Reviewer'))
#
# def clean(self):
# for name, field in self.fields.items():
# if isinstance(field, StaticField):
# self.cleaned_data.update({name: self.initial[name]})
#
# return self.cleaned_data
|
More like this
- Multiple-Submit-Button Widget for Choice Field by Archatas 4 years, 9 months ago
- ImageField for admin with thumbnail by semente 3 years, 11 months ago
- BetterForm with fieldsets and row_attrs by carljm 4 years, 3 months ago
- boostrap prepend-input for widgets by DimmuR 7 months, 4 weeks ago
- boostrap append-input for widgets by DimmuR 7 months, 4 weeks ago
Comments