Grokking Django
0% completed
Handling GET and POST Requests in DRF
Two HTTP methods do most of the work in the blog API: GET reads articles, and POST creates them. The plain Django version of that endpoint was a function of about 30 lines, most of them parsing and checks. With DRF, the same endpoint shrinks in three steps, from a function view to a class to a generic view of a few lines, and this lesson walks through each step.
All versions use the ArticleSerializer from the previous lesson, the ModelSerializer with read_only_fields = ["author", "published_date"] and the validate_title rule. Each version replaces the one before it at the same URL,
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%