1

I want to be able to use the bigserial data type for the pk of my django model. I do not want to do it manually with each model i create. Is there any way to change django to use bigserial instead of the serial datatype? All the searches i have done result in having to change the database for each model or a workaround but with an earlier version of django in like the 1.x version. Is there a more recent or better way to do this?

luis
  • 13
  • 7
  • You [can inherit from a model that defines the BigAutoField as the primary_key](https://stackoverflow.com/questions/44840299/changing-django-default-pk-with-autofield-to-bigautofield)? It kind of comes down to what "do it manually" means for you in that case.. – MatsLindh Mar 13 '20 at 21:05
  • Well the only answers I’ve been able to find require me to go into the database and change the ID each time I create a new table or require me to run a script that will change it every time I create a new table again – luis Mar 14 '20 at 01:58
  • I want a way for me to simple write my models like normal and when I makemigration and migrate, for it to simple already be bigserial – luis Mar 14 '20 at 01:58
  • In the example in the link above you extend your models from `BigPkAbastract` and everything is handled automagically for you. – MatsLindh Mar 14 '20 at 13:07

0 Answers0