Upgrade to Pro — share decks privately, control downloads, hide ads and more …

djangowebapi.pdf

 djangowebapi.pdf

Ngazetungue Muheue

February 19, 2020
Tweet

More Decks by Ngazetungue Muheue

Other Decks in Programming

Transcript

  1. ME Ø Python Software Foundation fellow Ø Python Society of

    Namibia co-founder Ø PyCon Namibia organiser Ø I work with Python and Django
  2. What does “API” mean? Ø Application Programming Interface Ø Code

    that allows two software programs to communicate with each other Ø It helps in connecting various software components Ø An API make it easier for developers to use certain technologies in building application using predefined operations.
  3. What is a REST API? Ø REST is an acronym

    for Representational State Transfer Ø When Services: use REST architecture , they are called RESTful APIs Ø Set of web address respond with pure information, not formatted web page Ø It returns JSON Ø Surrounded by quotation marks, [],{} and descriptive title for each bit of information GET - Retrieve a resource based on given conditions. POST - create a resource. PUT - update a resource with the given updated attributes. DELETE - delete a resource. When?
  4. GET request from GitHub's API Ø Many packages or many

    way Ø Django Rest framework Ø Sit on top of existing Django code
  5. Building an “API” Ø Many packages or many way Ø

    Django Rest framework Ø Sit on top of existing Django code
  6. Django Rest Framework Ø DRF is a Third Party Application

    that we will use in conjunction with our own application to create a REST API. Ø It provides us with many features that connect deeply with Django’s existing structures Ø Help us to create RESTful HTTP resources that correspond to the models we create Ø Sit on top of existing Django code
  7. Building the Serializer Ø Serializers allow object state to be

    translated into a format that can be stored or transmitted and be reconstructed later on. Ø The serializers in REST framework work very similarly to Django’s Form and ModelForm classes. Ø Serializers allow complex data such as querysets and model instances to be converted to native Python datatypes Ø Easily rendered into JSON, XML or other content types
  8. API - JSON Operation HTTP Method ØCreate POST ØRead GET

    ØUpdate PUT, PATCH ØDelete DELETE
  9. Always visit Ø https://www.django-rest-framework.org/ Ø https://www.djangoproject.com/ Ø https://www.python.org/ RESOURCES Source

    code – Ticket Api Ø https://github.com/Ngazetungue/restticketapi My slide: https://speakerdeck.com/muheuenga20/djangowebapi