urls.py오류
사용이유urlpatterns = router.urls

않이 편해짐 자동으로 처리해줌
urls.py 안됐던이유
TypeError: 'module' object is not iterable ImproperlyConfigured: The included URLconf 'note.urls' … does not appear to have any patterns
원인
note/urls.py에urlpatterns변수가 없거나, 리스트 형식이 아니었음.urlpatterns이름을 잘못 쓰거나(urlpattenrs등),include()를 잘못 사용.
해결note/urls.py에
python복사편집urlpatterns = [
path('diary/', note_list),
path('diary/edit/<int:pk>/', note_detail), ]같이 반드시 리스트로 정의.
프로젝트 루트
diary/urls.py에path('api/', include('note.urls'))추가.
오류ImportError: cannot import name 'NoteViewSet' from 'note.views'
원인
note/views.py가 기본으로 생성된 “빈 파일” 상태였음.
해결views.py에 아래 클래스를 추가:from rest_framework import viewsets
from .models import Note
from .serializers import NoteSerializerclass NoteViewSet(viewsets.ModelViewSet):
queryset = Note.objects.all()
serializer_class = NoteSerializer
urls
처음부터path('api/', include('note.urls')), 이거 때문에 안됐음
해결 방법 주석 처리하고 migrate하고 migration 하고 주석 풀면 쉽게 됐음