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.
Install required packages
sudo apt-get install python-pip python-dev build-essential
sudo pip install djangorestframework
sudo apt-get install python-virtualenv
$ mkdir tutorial
$ cd tutorial/
$ virtualenv env
$ source env/bin/activate
(env)tutorial$ pip install django
(env)tutorial$ pip install djangorestframework
(env)tutorial$ django-admin.py startproject tutorial .
Notice: the dot ( . ) at the end of command.
(env)tutorial$ cd tutorial/
(env)tutorial/tutorial$ django-admin.py startapp quickstart
(env)tutorial/tutorial$ cd ..
(env)tutorial$ python manage.py migrate
(env)tutorial$ python manage.py createsuperuser
Username (leave blank to use ‘myuser’): admin
Email address: [email protected]
Password:
Password (again):
Superuser created successfully.
[note] we set password as, password123
(env)tutorial$ cd tutorial/quickstart/
(env)tutorial/tutorial/quickstart$ vim serializers.py
(env)tutorial/tutorial/quickstart$ vim views.py
(env)tutorial/tutorial/quickstart$ cd ..
(env)tutorial/tutorial$ vim urls.py
(env)tutorial/tutorial$ vim settings.py
(env)tutorial/tutorial$ cd ..
(env)tutorial$ python manage.py runserver
Performing system checks…
System check identified no issues (0 silenced).
December 21, 2016 – 12:17:58
Django version 1.10.4, using settings ‘tutorial.settings’
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Reference : https://realpython.com/blog/python/django-rest-framework-quick-start/
http://www.django-rest-framework.org/tutorial/quickstart/
http://www.django-rest-framework.org/
https://eureka.ykyuen.info/2014/08/19/django-setup-django-rest-framework/