0

I have a bunch of FlatPages on my django website and would like to translate their content in different languages from the Admin using the django-modeltranslations pacakge. Here is my code:

class TinyMCEFlatPageAdmin(FlatPageAdmin):    
    def formfield_for_dbfield(self, db_field, **kwargs):
        if db_field.name.startswith('content'):
            return db_field.formfield(widget=TinyMCE(attrs={'cols': 80, 'rows': 30},))
        return super().formfield_for_dbfield(db_field, **kwargs)

Basically, I created a TinyMCEFlatPageAdmin class from the default one FlatPageAdmin to display the Flatpage content in HTML on the admin site. As far as the translation is concerned, i added the following code:

class MyTranslatedFlatPageAdmin(TinyMCEFlatPageAdmin, TabbedTranslationAdmin):
    def formfield_for_dbfield(self, db_field, **kwargs):
        field = super().formfield_for_dbfield(db_field, **kwargs)
        self.patch_translation_field(db_field, field, **kwargs)
        return field

I have then registered the new MyTranslatedFlatPageAdmin class:

admin.site.unregister(FlatPage)
admin.site.register(FlatPage, MyTranslatedFlatPageAdmin)

When i log in to the flatpage content page i receive the following error:

formfield_for_dbfield() takes 2 positional arguments but 3 were given

I am struggling to find out why as everything seems to be correct to me. Thanks in advance for your help

AntoG
  • 833
  • 1
  • 10
  • 16

1 Answers1

0

I fixed it by downgrading to version 0.13.1. It seems a bug with the version 0.15.0 of the package.

AntoG
  • 833
  • 1
  • 10
  • 16