most likely due to a circular import

오류가 떳다. 검색해보니 순환 참조 문제라는데 Foreignkey를 정의 할 때 서로 불러오게 해서 생긴 문제인 것 같다. 

 

Course와 Lecture가 있는데 Course는 여러개의 Lecture를 가질 수 있고 반대의 경우에도 그렇다. 

그래서 모델을 정의 할 때 

from lecture.models import Lecture

lectures = models.ManyToManyField('lecture.Lecture', blank=True)
from course.models import Course

courses = models.ManyToManyField(Course, blank=True)

이런 방식이 아닌 

 

from course.models import Course

courses = models.ManyToManyField(Course, blank=True)
lectures = models.ManyToManyField('lecture.Lecture', blank=True)

이런식으로 정의해줘야한다. 

'Back-End > Django' 카테고리의 다른 글

Django 이미지 업로드  (0) 2021.07.23
Static 사용할 때  (0) 2021.07.21
templates extends 관련  (0) 2021.07.21
Django 자동으로 Redirect 될 때  (0) 2021.07.12
Django Admin 페이지 수정  (0) 2021.07.11

+ Recent posts