Skip to content Skip to sidebar Skip to footer

Alterfield On Auto Generated _ptr Field In Migration Causes Fielderror

I have two models: # app1 class ParentModel(models.Model): # some fields Now, in another app, I have child model: # app2 from app1.models import ParentModel class ChildModel

Solution 1:

If your code supports it, you could just change the parent class to an abstract class and have all the fields in the child model. However, if you still do need the parent object separately, then I don't think you can change the Django OneToOne link without some serious hacking (not recommended).

If you only need the relation and don't need the methods, etc. then you could remove the inheritance and go with a self-created either OneToOneField or an IntegerField that holds the ForeignKey to that other object. You could elaborate the question with your end goal, so it would be simpler to offer real solutions rather than theories.

Post a Comment for "Alterfield On Auto Generated _ptr Field In Migration Causes Fielderror"