Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Initial value for django model autofield

I'm creating an app in django that will eventually be filled with data from its predecessor. I'd like to have certain models start their auto-increment counter at 10000 to differentiate this data in advance and keep the pk accounting consistant. How can I do this in the model? AutoField doesn't seem to take parameters that would let me do this.

like image 950
Chris Keele Avatar asked Aug 04 '26 18:08

Chris Keele


1 Answers

This isn't a question about Django. AutoField is simply a representation of the underlying database's autoincrement property, and Django doesn't control it. Depending on your database backend, you might be able to reset the autoincrement start value: look at your db's documentation for details.

like image 195
Daniel Roseman Avatar answered Aug 07 '26 13:08

Daniel Roseman