How can set two primary key fields for my models in Django

前端 未结 3 2105
一整个雨季
一整个雨季 2020-12-07 17:46

I have a model like this:

class Hop(models.Model):
    migration = models.ForeignKey(\'Migration\')
    host = models.ForeignKey(User, related_name=\'host_se         


        
3条回答
  •  渐次进展
    2020-12-07 18:13

    Currently, Django models only support a single-column primary key. If you don't specify primary_key = True for the field in your model, Django will automatically create a column id as a primary key.

    The attribute unique_together in class Meta is only a constraint for your data.

提交回复
热议问题