[Django]-Django autoincrement field

5👍

By default, Django gives each model the autoincrement field called id. See https://docs.djangoproject.com/en/2.1/topics/db/models/#automatic-primary-key-fields

If you want to create an extra auto increment field, you can use AutoField https://docs.djangoproject.com/en/2.1/ref/models/fields/#django.db.models.AutoField

Create custom id field

class MyModel(models.Model):
    wo_id = models.AutoField(primary_key=True)

This skips creation of default id field and creates autoincrement primary field with name wo_id.

👤quick

Leave a comment