csev/dj4e-samples

python manage.py check warning issue with Django3.2 and latest version

sumendrabsingh opened this issue · 3 comments

When you want to use social login, please see dj4e-samples/github_settings-dist.py
Using registration/login.html as the login template
System check identified some issues:

WARNINGS:
autos.Auto: (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 AutosConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.
social_django.Nonce: (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 PythonSocialAuthConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.
193 'social_core.backends.github.GithubOAuth2',
users.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 UsersConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigA
utoField'.
well.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 WellConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAu
toField'.
System check identified 42 issues (0 silenced).

Fix : Add Default primary key field type
If the similar issue exits please make include the following line inside your project setting.py file

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

Reference: https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field

Alternatively you may change the Django version in the requirements.txt, it works with Django 3.0.x and 3.1.x

csev commented

Thanks! This looks like the simplest solution that works for 3.1 and 3.2:

https://stackoverflow.com/questions/67783120/warning-auto-created-primary-key-used-when-not-defining-a-primary-key-type-by

Update settings.py - I am working on a fix and will test.

csev commented

So I made a change into the settings.py in this and all my other projects and updated them to Django 3.2 and reloaded them - and I think I fixed this for Django 3.2 does not have warnings. Please let me know if you think this is not the case. Thanks so much.