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


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 (new in Django 3.2)

Either add this into 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