Grokking Django
0% completed
Creating a Simple API with Django Views
from django.http import JsonResponse JsonResponse({"title": "Getting started with Django"})
That one line is a complete JSON response in plain Django. JsonResponse converts the dictionary to JSON, sets the Content-Type header to application/json, and returns status 200. Before you rely on DRF, it is worth building the blog's article API with nothing else, because every line you write by hand here is a line DRF later writes for you.
This lesson builds two endpoints with ordinary function views: a list of articles that also accepts new ones, and a single article
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%