발생과정
갑자기 Django의 개발 서버를 실행할 때 해당 이슈가 발생했다. 다만, 서버가 실행은 정상적으로 작동했다.
오류
System check identified 2 issues (0 silenced).
May 31, 2021 - 15:36:33
Django version 3.2.3, using settings 'config.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
E:\project\todolist_renewal\config\settings.py changed, reloading.
Watching for file changes with StatReloader
Performing system checks...
System check identified some issues:
WARNINGS:
todos.Todo: (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 TodosConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.
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.BigAutoField'.
이 오류는 Django의 새로운 버젼에 추가된 기능때문에 발생한 오류이다.
기존의 Django에서 새로운 Model을 만들 때 따로 기본 키를 생성하지 않아도 자동으로 integer field로 생성해주었다. 여기서 Django 3.2에서는 setting에서 자동으로 생성되는 기본 키의 유형을 사용자가 지정할 수 있게 해주었다.
그래서 3.2로 업그레이드하면 명시적으로 정의된 기본 키 유형이 없다는 사실에 대한 경고가 표시된다.
해결법
나의 경우 setting에 DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'를 추가하여 해결했다.
출처
https://dev.to/rubyflewtoo/upgrading-to-django-3-2-and-fixing-defaultautofield-warnings-518n
Upgrading to Django 3.2 and fixing DEFAULT_AUTO_FIELD warnings
When you define a model in Django without specifying a primary key, Django will automatically create...
dev.to
'개발 공부 > Django' 카테고리의 다른 글
django channels - Tutorial Part 3: Rewrite Chat Server as Asynchronous (0) | 2021.07.04 |
---|---|
django channels - Tutorial Part 2: Implement a Chat Server (0) | 2021.07.04 |
django channels - Tutorial Part 1: Basic Setup (0) | 2021.07.03 |
Serializer (0) | 2021.06.22 |
Django 기술 면접 질문들 (0) | 2021.06.13 |