devgraphy / airsm-django-restapi

AIRSM 프로젝트의 REST API 기반 Back-end
0 stars 0 forks source link

DoesNotExist at /membership/rank/. Member matching query does not exist. #10

Closed devgraphy closed 3 years ago

devgraphy commented 3 years ago
DoesNotExist at /membership/rank/
Member matching query does not exist.
Request Method: GET
Request URL:    http://localhost:8000/membership/rank/
Django Version: 3.1.5
Exception Type: DoesNotExist
Exception Value:    
Member matching query does not exist.
Exception Location: C:\Users\albei\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\models\query.py, line 429, in get
Python Executable:  C:\Users\albei\AppData\Local\Programs\Python\Python39\python.exe
Python Version: 3.9.1
Python Path:    
['D:\\development\\airsm\\airsm_restapi',
 'C:\\Users\\albei\\AppData\\Local\\Programs\\Python\\Python39\\python39.zip',
 'C:\\Users\\albei\\AppData\\Local\\Programs\\Python\\Python39\\DLLs',
 'C:\\Users\\albei\\AppData\\Local\\Programs\\Python\\Python39\\lib',
 'C:\\Users\\albei\\AppData\\Local\\Programs\\Python\\Python39',
 'C:\\Users\\albei\\AppData\\Roaming\\Python\\Python39\\site-packages',
 'C:\\Users\\albei\\AppData\\Roaming\\Python\\Python39\\site-packages\\win32',
 'C:\\Users\\albei\\AppData\\Roaming\\Python\\Python39\\site-packages\\win32\\lib',
 'C:\\Users\\albei\\AppData\\Roaming\\Python\\Python39\\site-packages\\Pythonwin',
 'C:\\Users\\albei\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages',
 'C:\\Users\\albei\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\paho_mqtt-1.5.1-py3.9.egg']

console error

raise self.model.DoesNotExist(
membership.models.Member.DoesNotExist: Member matching query does not exist.
[26/May/2021 22:47:31] "GET /membership/rank/ HTTP/1.1" 500 110007
devgraphy commented 3 years ago

urls.py

urlpatterns = [
    path('rank/',getRank),
    path('hello/',helloAPI),
    path('users/',userList),
    path('<str:id>/',getUser),
]

위치를 수정하니 views를 못 찾는 문제는 해결... 그 이유는...?

devgraphy commented 3 years ago

이후 TypeError at /membership/rank/ Thefieldsoption must be a list or tuple or "__all__". Got str. 문제가 바로 발생...

class RankSerializer(serializers.ModelSerializer):
    class Meta:
        model = Rank
        fields = ['who']

fields = ('who') -> ['who'] 로 변경하여 해결

devgraphy commented 3 years ago

Rank 정보는 테이블로 따로 관리하는 것보다 view 단에서 userlist를 points필드로 내림차순 정렬하여 API로 제공하는 방식으로 해결