Skip to content

Latest commit

 

History

History
49 lines (35 loc) · 695 Bytes

File metadata and controls

49 lines (35 loc) · 695 Bytes

Django rest framework tutorial

1. Create a new project

django-admin startproject core .

2. Create a new app

python manage.py startapp api

3. Add the app to the project

# tutorial/settings.py
INSTALLED_APPS = [
    ...
    'quickstart',
]

4. Create a view

# quickstart/views.py
from rest_framework.decorators import api_view
from rest_framework.response import Response

@api_view(['GET'])
def hello_world(request):
    return Response({'message': 'Hello, World!'})

5. Create a URL

# quickstart/urls.py
from django.urls import path
from .views import index

urlpatterns = [
    path('index', index),
]