12👍
✅
It works exactly the same way. The TabularInline and StackedInline classes also have a formfield_for_dbfield method, and you override it the same way in your subclass.
8👍
Since Django 1.1, formfield_overrides is also working
formfield_overrides = {
models.ImageField: {'widget': AdminImageWidget},
}
👤luc
3👍
Working example:
class PictureInline(admin.StackedInline):
model = Picture_Gallery
extra = 3
def formfield_for_dbfield(self, db_field, **kwargs):
if db_field.name == 'name':
kwargs['widget'] = MyWidget()
return super(PictureInline,self).formfield_for_dbfield(db_field,**kwargs)
- ImportError: DLL load failed : – when trying to import psycopg2 library
- Django 'ascii' codec can't encode character
- Is there any list of blog engines, written in Django?
Source:stackexchange.com