https://www.django-rest-framework.org/
python manage.py startapp api

pip install djangorestframework
pip install markdown # Markdown support for the browsable API.
pip install django-filter # Filtering support


INSTALLED_APPS = [
(... 생략 ...)
'api',
'rest_framework',
'django_filters',
]
urlpatterns = [
(... 생략 ...)
path("hello_world/", hello_world),
]
#dev_48
#기존방식
def hello_world(request):
return HttpResponse('Hello World!')
#DRF 방식
아래와 같다

urlpatterns = [
path("hello_world/", hello_world),
path("hello_world_drf/", hello_world_drf),
]
Response 는 drf 에 있는 함수로 dictionary로 보내야 한다.
#https://www.django-rest-framework.org/api-guide/views/#api_view
#DRF 방식
@api_view(['GET'])
def hello_world_drf(request):
return Response({"message":'Hello World!'})
