mysite-virtualenv) 10:43 ~/django-blog (master)$ ./manage.py migrate
System check identified some issues:
WARNINGS:
blog.Comment: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the BlogConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'dja
ngo.db.models.BigAutoField'.
blog.Post: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the BlogConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'dja
ngo.db.models.BigAutoField'.
users.Profile: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the UsersConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'dj
ango.db.models.BigAutoField'.
Operations to perform: Apply all migrations: admin, auth, blog, contenttypes, sessions, users Running migrations: No migrations to apply.
From the Auto Created Primary Key [Django Doc]
To avoid unwanted migrations in the future, either explicitly set DEFAULT_AUTO_FIELD to AutoField
Add DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
in your settings.py
If you want to set your field type per app basis then you can specify per app basis
from django.apps import AppConfig
class MyAppConfig(AppConfig):
default_auto_field = 'django.db.models.AutoField'
name = 'my_app'
or even you can specify per model basis as
from django.db import models
class MyModel(models.Model):
id = models.AutoField(primary_key=True)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With