Skip to Content
Django RESTful Web Services
book

Django RESTful Web Services

by Gastón C. Hillar
January 2018
Intermediate to advanced
326 pages
7h 38m
English
Packt Publishing
Content preview from Django RESTful Web Services

Saving information about users that make requests

Whenever a user performs an HTTP POST request to the drone resource collection to create a new drone resource, we want to make the authenticated user that makes the request the owner of the new drone. In order to make this happen, we will override the perform_create method in the DroneList class declared in the views.py file.

Open the restful01/drones/views.py file and replace the code that declares the DroneList class with the following code. The new lines are highlighted in the code listing. The code file for the sample is included in the hillar_django_restful_08_01 folder, in the restful01/drones/views.py file:

class DroneList(generics.ListCreateAPIView): queryset = Drone.objects.all() ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Building Versatile Mobile Apps with Python and REST: RESTful Web Services with Django and React

Building Versatile Mobile Apps with Python and REST: RESTful Web Services with Django and React

Art Yudin

Publisher Resources

ISBN: 9781788833929Supplemental Content