Auto-Created Primary Key Used When Not Defining A Primary Key Type, By Default ‘Django.Db.models.AutoField’.

Auto-created primary key used when not defining a primary key type, by default

'django.db.models.AutoField'.

Your models do not have primary keys. But they are being created automatically by django.

You need to choose type of auto-created primary keys https://docs.djangoproject.com/en/3.2/releases/3.2/#customizing-type-of-auto-created-primary-keys (new in Django 3.2)

Either add this into settings.py DEFAULT_AUTO_FIELD='django.db.models.AutoField'

or add id in your models

class Topic(models.Model):
id = models.AutoField(primary_key=True)
...

Leave a Comment