Mar 06, 2015 · Updated: Jul 12, 2021 · by Tim Kamanin
Override all widgets of a given type in a form. In this example we set CKEditor widget for all textfields in the form.
class BlogAdmin(admin.ModelAdmin):
formfield_overrides = {
models.TextField: {"widget": CKEditorWidget},
}
Override widget only for a desired field in the form.
class BlogAdminForm(ModelForm):
class Meta:
model = Blog
widgets = {
"body": CKEditorWidget(),
}
class BlogAdmin(admin.ModelAdmin):
form = BlogAdminForm
Hey, if you've found this useful, please share the post to help other folks find it: