django-polymorphic icon indicating copy to clipboard operation
django-polymorphic copied to clipboard

New polymorphic parent model for already polymorphic model

Open mhmousavi opened this issue 4 years ago • 0 comments

Hello and thank you for your great package. I've faced a little problem with migrating when I set new parent class for my polymorphic subclass. Here is an example:

before:

class Exam(PolymorphicModel):
	# Exam model fields ...

after:

class ParentExam(PolymorphicModel):
	# some new fields ...

class Exam(ParentExam):
	# changes in exam fields

After these changes, I can't migrate cause I have to populate 'parentexam_ptr_id' field for exam model in my migrations and there is no easy way to set or make default ParentExam model for each Exam instance.

I've found several answers but they all recommended to duplicate my database (like this one).

I'm looking for much easier and more sensible ways to solve this problem. Thank you in advance.

mhmousavi avatar Apr 10 '21 15:04 mhmousavi