I'm using django-modeltranslation to translate one of my model. Everything is fine for now, except that my previous widget isn't working anymore. It tried many things, including this :
class EmailTemplateAdmin(admin.ModelAdmin):
def formfield_for_dbfield(self, db_field, **kwargs):
if db_field.name == 'body':
kwargs['body'] = TinyMCE(attrs={'cols': 80, 'rows': 30})
return db_field.formfield(**kwargs)
return super(EmailTemplateAdmin, self).formfield_for_dbfield(db_field, **kwargs)
class TranslatedEmailTemplateAdmin(EmailTemplateAdmin, TabbedTranslationAdmin):
def formfield_for_dbfield(self, db_field, **kwargs):
field = super(TranslatedEmailTemplateAdmin, self).formfield_for_dbfield(db_field, **kwargs)
self.patch_translation_field(db_field, field, **kwargs)
return field
According to the documentation of django-modeltranslation about this case, it's the proper way to do this.
I'm not asking for a solution for my own problem, because I guess it might be something in my own code that breaks the thing. I'd just like to have an example of using a widget on a field in django admin that uses modeltranslation... Thanks ! :)
Using Django == 1.6.7 and django-modeltranslation==0.7.3