如何让Django AutoField以更高的数字开始 [英] How to get Django AutoFields to start at a higher number

查看:164
本文介绍了如何让Django AutoField以更高的数字开始的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于我们的Django应用程序,我们希望获得一个 AutoField 以不同于1的数字开始。似乎没有一个明显的方法这个。任何想法?

解决方案

像其他人一样,在数据库方面比Django方面要容易一些。



对于Postgres,它将是像这样 ALTER SEQUENCE sequence_name RESTART WITH 12345; 查看您自己的DB引擎的文档,了解您在那里的做法。 p>

For our Django App, we'd like to get an AutoField to start at a number other than 1. There doesn't seem to be an obvious way to do this. Any ideas?

解决方案

Like the others have said, this would be much easier to do on the database side than the Django side.

For Postgres, it'd be like so: ALTER SEQUENCE sequence_name RESTART WITH 12345; Look at your own DB engine's docs for how you'd do it there.

这篇关于如何让Django AutoField以更高的数字开始的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆