django中不支持双主键、多主键。

要实现类似功能可以:

classMeta:

unique_together=(("driver","restaurant"),)

里边两个元素联合去重的。 既是复合主键

注意使用这种方法不要设置主键,让django自己生成一个id作为主键即可。

参考:http://docs.djangoproject.com/en/dev/ref/models/options/#unique-together

 

相关文章:

  • 2018-11-14
  • 2021-12-16
  • 2022-12-23
  • 2021-09-14
  • 2021-07-04
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-10-11
  • 2021-06-20
  • 2022-03-03
  • 2022-12-23
  • 2021-07-31
相关资源
相似解决方案