This is easy for non-inlines. Just override the following in the your admin.py AdminOptions:
def formfield_for_dbfield(self, db_field, **kwargs):
if db_field.name == 'photo':
kwargs['widget'] = AdminImageWidget()
return db_field.formfield(**kwargs)
return super(NewsOptions,self).formfield_for_dbfield(db_field,**kwargs)
I can't work out how to adapt this to work for inlines.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With