Answers for "Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'."

1

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)
    ...
Posted by: Guest on October-05-2021

Code answers related to "Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'."

Python Answers by Framework

Browse Popular Code Answers by Language