Installing Django and Django-REST Framework on Ubuntu for developing REST API’s

Django REST framework is a powerful and flexible toolkit for building Web APIs. Some reasons you might want to use REST framework:

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 )”

Leave a Comment