Heim  >  Fragen und Antworten  >  Hauptteil

python - django model中的ID字段如何设置自增的初始化值呢?

比如从100000000开始自增,因为是订单编号,确保必须唯一,然后16位,so..

PHP中文网PHP中文网2741 Tage vor1066

Antworte allen(1)Ich werde antworten

  • 巴扎黑

    巴扎黑2017-04-18 10:28:05

    这个尽量在数据库级别去做;比如 postgresql 执行 ALTER SEQUENCE sequence_name RESTART WITH 12345;然后自己测试,自己测试成功时候新建 migration 文件,把语句丢到 migration 文件中去,自定义 migration 你应该懂得,然后 over

    Antwort
    0
  • StornierenAntwort