Django unique_together on sub-class model for parent attribute?

后端 未结 3 2174
青春惊慌失措
青春惊慌失措 2021-02-19 10:43

In this:

class Administrator(models.Model):
    user = models.OneToOneField(User, primary_key=True)
    account = models.ForeignKey(Account)

    class Meta:
            


        
3条回答
  •  眼角桃花
    2021-02-19 11:01

    What you are missing is abstract = True in the base class. This creates a table with all the fields for the subclass.

提交回复
热议问题