I have custom textfield widget and many form in my project. To use this custom widget i need to to write:
formfield_overrides = {
TextField: {'widget': CustomTextFieldWidget},
}
in every admin.ModelAdmin form, and that’s just ugly.
Is there a way to write it just once and use custom widget across all forms in project?
No, there is no hook to override formfield widgets across an entire project.
You could make all of your model admin classes inherit from a subclass of
admin.ModelAdmin, then you only have to setformfield_overridesonce.