【Django】AutoFieldで出くわしたエラーの解決策

※本サイトにはプロモーション・広告が含まれています。

(最終更新月:2021年8月)

django-allauthを使った際に、下記のエラーが出てきてしまいました

WARNINGS:
 account.EmailAddress: (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 AccountConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.
 account.EmailConfirmation: (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 AccountConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.
 accounts.GroupSettings: (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 AccountsConfig.default_auto_field attribute to point 
 to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.
 accounts.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 AccountsConfig.default_auto_field attribute to point 
 to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.
 accounts.User: (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 AccountsConfig.default_auto_field attribute to point 
 to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.
 efault 'django.db.models.AutoField'.
 oint to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.
 socialaccount.SocialApp: (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 SocialAccountConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.
 socialaccount.SocialToken: (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 SocialAccountConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.

備忘録も兼ねて解決策は下記の通りです!

settings.py内で、

 DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'

を記載しましょう!

タイトルとURLをコピーしました