Lesson: Django REST Framework Introduction
About Lesson

In this Django REST Framework lesson we are going to learn about Django REST Framework Introduction & Installation.



What are RESTFull API’s

A RESTful API acts as a translator between two machines communicating over a Web service. If your familiar with the concept of API This is just like an API but it’s working on a RESTful Web service and the API is used by two applications trying to communicate with each other over a network or Internet.
Web developers program REST API that server can receive data from applications. These applications can be web-apps, Android/iOS apps, etc. RESTful APIs return JSON files which can be interpreted by a variety of devices.



What is Django ?

Django is a Python Web Framework that is used for web development. Django framework uses a set of design principles that produces one of the most productive web development processes compared to many other web frameworks. also Django provides a set of tightly integrated components. all of these components are developed by the Django team itself.




What is Django REST Framework 

Django REST framework is a powerful and flexible toolkit for building Web APIs.

Some reasons you might want to use REST framework:

  • The Web browsable API is a huge usability win for your developers.
  • Authentication policies including packages for OAuth1a and OAuth2.
  • Serialization that supports both ORM and non-ORM data sources.
  • Customizable all the way down – just use regular function-based views if you don’t need the more powerful features.
  • Extensive documentation, and great community support.
  • Used and trusted by internationally recognised companies including Mozilla, Red Hat, Heroku, and Eventbrite.





First of all we are going to install django, you can create virtual environment and after that install django using this command.



Now you need to install Django REST Framework.




OK after installation we need to create a new project in Django, and iam going to give the project name as APIProject.



Now our project is created let’s run our development server.



Now you can go to http://localhost:8000/, this will be the result.

Django REST Framework Introduction
Django REST Framework Introduction





Now let’s talk about the project structure that we have in our Django Project.

Django Project Structure
Django Project Structure



These files are as follows:


APIProject/: This is your project directory, which consists of the following files:

__init__.py: Python file to allow app packages to be imported from other
directories. Note __init__.py is not a Django specific file, it’s a generic file used in
almost all Python applications.

settings.py: This indicates settings and configuration for your project and contains initial default settings.

urls.py: This is the place where your URL patterns live. Each URL defined here is mapped to a view.

wsgi.py: This is the configuration to run your project as a Web Server Gateway Interface (WSGI)  Application


The generated settings.py file contains the project settings, including a basic configuration to use an SQLite 3 database and a list named INSTALLED_APPS, which contains common Django applications that are added to your project by default.


manage.py: This is a command-line utility used to interact with your project. It is a thin wrapper around the django-admin.py tool. You don’t need to edit this file.



To complete the project setup, we will need to create the tables in the database required by the applications listed in INSTALLED_APPS. Open the shell and run the following commands.



This  will be the output of migrate.

Thank you for visiting my website! If you enjoyed the free courses, please consider supporting my works on Patreon.
Exercise Files
No Attachment Found
No Attachment Found
0% Complete