11👍
✅
Is it possible to set a custom widget for a model in the model definition?
Yes, if you override the field: Specifying the form field for a model field.
👤jpic
0👍
For reference, based on formfield proposed in earlier answer:
def formfield(self, **kwargs):
kwargs['widget'] = CurrencyWidget
return super().formfield(**kwargs)
- Error "Could not load Boto's S3 bindings."
- How to use Django variable in JavaScript file?
- Django Ajax "FORBIDDEN" error
- Form is not valid… WHY?
Source:stackexchange.com