Answer the question
In order to leave comments, you need to log in
Migrating existing model data to MPTTModel?
There is a data model. Installed django-mptt, but how do I now migrate data from the old model to the new MPTTModel?
Tag(models.Model):
name = models.CharField(u'Название', max_length=255, unique=True)
parent = models.ForeignKey('self', verbose_name='Родительский тег', null=True, blank=True, related_name='children')
Tag(MPTTModel):
name = models.CharField(u'Название', max_length=255, unique=True)
parent = TreeForeignKey('self', on_delete=models.CASCADE, verbose_name='Родительский тег', null=True, blank=True, related_name='children')
Answer the question
In order to leave comments, you need to log in
$ python manage.py shell
In [1]: from some_app.models import Tag
In [2]: Tag.objects.rebuild()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question