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.
Following post details about how you can get started with simple helloproject example to setup DJANGO REST Framework.
$ mkdir workspace
$ cd workspace
$ sudo apt-get install python3-venv
Following command, Creates a new virtual environment by running,
$ python3 -m venv PATH_TO_CREATE_ENVIRONMENT_DIRECTORY
Note: You can set any directory for virtual environment, lets say we want to create environment in current directory, then you can use below command but if you want create environment in “/home/devlab/virtualenvs” directory, the below command will be “python3 -m venv /home/devlab/virtualenvs”
$ python3 -m venv env
The final step in setting up your virtual environment is to activate it:
$ source env/bin/activate
Now, we need to install “django” and “django rest framework” using below command,
(env)$ pip install django
(env)$ pip install djangorestframework
With these steps we have installed Django and Django REST Framework development environment software to actually start development to create our REST API’s.
To continue next with developing your first REST API, please refer to next post “Developing first REST API using Django Rest Framework ( DRF )”