Ichbinstudent
Ichbinstudent

Reputation: 21

Using django-import-export together with django-parler

I'm trying to import and export models using django-import-export while having TranslatedFields from django-parler.

Although I explicitly added Description to the Meta fields in ChildInsurancePlanResource it's not showing up when importing items. Name is showing up.

I don't know how to make django-import-export recognize those fields and import them as the default language.

My admin.py looks like this:

class ChildInsurancePlanResource(resources.ModelResource):
    class Meta:
        model = InsurancePlan
        fields = (
            "id",
            "Name",
            "Description"
        )

class ChildInsurancePlanAdmin(TranslatableAdmin, PolymorphicChildModelAdmin, ImportExportModelAdmin):
    resource_class = ChildInsurancePlanResource

    base_form = TranslatableModelForm
    base_model = InsurancePlan


admin.site.register(ChildInsurancePlan, ChildInsurancePlanAdmin)

The model is defined like this:

class InsurancePlan(PolymorphicModel):
    Name = models.CharField(max_length=128)


class ChildInsurancePlan(InsurancePlan, TranslatableModel):
    objects = InsurancePlanManager()

    translations = TranslatedFields(
        Description=models.TextField(_("Description"), max_length=5000),
    )

Upvotes: 2

Views: 268

Answers (0)

Related Questions