1👍
✅
Normally you should use formfield_overrides property in TabularInline or StackableInline defenition.
For example:
from django.contrib import admin
from myapp.models import City, Shop
class ShopInline(admin.TabularInline):
formfield_overrides = {
models.PointField: {'widget': Textarea},
}
model = Shop
class CityAdmin(admin.ModelAdmin):
inlines = [ShopInline,]
But If you want set widget for all inlines:
class DirectAdmin(admin.ModelAdmin):
def get_inline_instances(self, request, obj=None):
overrides = {
models.PointField: {'widget': Textarea},
}
inline_instances = super(DirectAdmin, self).get_inline_instances(request, obj=obj)
for inline in inline_instances:
inline.formfield_overrides = overrides
return inline_instances
For better understanding please inspect get_inline_instance definition
Source:stackexchange.com