Django Api REST Framework

REST Django framework is a powerful and flexible toolkit for building Web APIs.
Some reasons you might want to use the REST framework:
• The Web can be explored API is a big usability victory for your developers.
• Authentication policies include packages for OAuth1a and OAuth2.
• Serialization that supports ORM and non-ORM data sources.
• Customizable all the way — using only the usual function-based views if you don’t need more powerful features.
• Extensive documentation, and exceptional community support.
• Used and trusted by internationally recognized companies including Mozilla, Red Hat, Heroku, and Eventbrite.

What is needed in making DjangoAPI ?
REST framework requires the following:
• Python (2.7, 3.4, 3.5, 3.6, 3.7)
• Django (1.11, 2.0, 2.1)
The following packages are optional:
• coreapi (1.32.0+) — Support schema formation.
• Price reduction (2.1.0+) — Decreased support for APIs that can be explored.
• django-filter (1.0.1+) — Filtering support.
• Django-crispy-forms — Improved HTML display for filtering.
• django-guardian (1.1.1+) — Support object level permission.

Installation
Install using pip, including whatever optional packages you want …
# pip install djangorestframework

when installing djangorestframework make sure you save it in setting.py

Django Rest Framework
DRF handles the large appointment of the transformation of our database model into a RESTful API. There are two main steps for this process: the first serializer is used to convert data into JSON so that it can be sent via the internet, then View is used to determine what data is sent.

JSON
It’s important to note that since an API is communicating with another computer information being shared is not what would be sent for a standard web page. When your browser requests, for example, the Google homepage, it sends HTTP requests and receives HTTP responses with HTML, CSS, JavaScript, images, and so on.

An API is different. Typically we’re only interested in the data from a database. This data is often transformed into JSON format to be efficiently transmitted about. The API will also have a series of well-defined rules for how a frontend client can interact with it via a REST architecture. To register a new user the frontend framework will need access to the called endpoint API, for example, / api / register API. This API endpoint contains both a specific URL route and its own set of permissions.

I will also display a web of fire that I made and will be explained one by one

this is the initial display when you call localhost http://127.0.0.1:8080/api/ which looks the same as the index display or home that comes from views.py scripts

and this is a hello list to post the name you entered in the form that is already available on the web

when you call the server http://127.0.0.1:8080/api/profile/ it will appear like this, this is a display to create a new account.

Check out that! The fire / endpoint displays all three of my blog posts in JSON format. It also shows in the header that only GET, HEAD, OPTIONS are allowed.

Now when you have created an account, you can log in directly with the account that was created just now on the server http://127.0.0.1:8080/api/login/

like that more or less the web that I made from django api is hopefully hopefully useful thanks

Like what you read? Give Kamal Oktaviana a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.