What value do I use for _ptr when migrating reparented classes with South?

后端 未结 2 1219
一生所求
一生所求 2021-02-19 13:50

I have two classes, one of which is descended from the other, and I would like to make them both sibling classes descended from the same base class.

Before:



        
2条回答
  •  萌比男神i
    2021-02-19 14:12

    If base will not be instantiated on its own, you can easily solve the problem using abstract = True prop to class Meta.

    Example code:

    from django.db import models
    
    class Base(models.Model):
        name = models.CharField(max_length=10)
        class Meta:
            abstract = True
    
    class A(Base):
        pass
    
    class B(Base):
        title = models.CharField(max_length=10)
    

提交回复
热议问题