T.I.L May 8, 2023 (Django url 설정 오류)

2023. 5. 8. 17:26T.I.L (Today_I_Learned)

발생한 문제


DRF 프로젝트를 진행하던 중 처음 보는 오류를 맞닥뜨렸습니다.

발생하게 된 순서를 되짚어 보면, 새로운 앱을 생성한 후 urls.py 폴더를 생성하고 해당 앱의 모델 구상까지 한 이후

makemigrations를 진행하던 중에 발생했습니다. 오류 메시지도 길었고 무엇보다 딱히 손댄게 없는 초기 단계에서

처음보는 오류가 발생해서 당황스러웠습니다.

오류 메시지는 아래와 같습니다

django.core.exceptions.ImproperlyConfigured: 
The included URLconf '<module 'posts.urls' from 'C:\\Users\\????\\algorithm_fc\\posts\\urls.py'>' does not appear to have any patterns in it. If you see the 'urlpatterns' variable with valid patterns in the file then the issue is probably caused by a circular import.

 

 

 

원인


메시지를 잘 읽어보니 제가 urls.py 폴더만 만들고 안에 아무런 내용도 넣지 않아서 발생한 문제였습니다.

 

 

해결


from django.urls import path

urlpatterns = [
]

위와 같이 빈 패턴이라도 정의를 해주면 해결되는 오류였습니다.