这对于非内联来说很容易。只需在 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)
我无法弄清楚如何使其适用于内联。