Answer the question
In order to leave comments, you need to log in
Django MPTT and Django-import-export. Error importing categories. How to decide?
Hello. I'm having this problem
I'm trying to import categories (which were created with Django MPTT) using Django-import-export but I'm getting this error
ValueError: Cannot assign "'Досуг'": "Category.parent" must be a "Category" instance.
class Category(MPTTModel):
name = models.CharField(max_length=50, unique=True)
parent = TreeForeignKey('self', null=True, blank=True, related_name='children', db_index=True)
class MPTTMeta:
order_insertion_by = ['name']
class CategoryResource(resources.ModelResource):
class Meta:
model = Category
exclude = ('lft', 'rght', 'tree_id', 'level')
class CategoryMPTTModelAdmin(ImportExportMixin, MPTTModelAdmin):
mptt_level_indent = 20
resource_class = CategoryResource
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question