DEV Community

loading...
Cover image for Setting Up Django Rest Framework

Setting Up Django Rest Framework

blackpandan profile image black_panda ・1 min read

Django Rest Framework (DRF)

Django framework is a powerful toolkit for building web API's

its comes with many interesting features which include:

  • a web_browsable_api
  • serialization that supports ORM

an API(application programming interface) gives us data when requests are sent to it.

this data is usually in the form of JSON(JavaScript Object Notation).

yes, it is not only for javascript

Django rest framework(DRF) helps us customize the requests handling and the outputs down to status codes.

to install it Django and python is required

python -m venv env
Enter fullscreen mode Exit fullscreen mode
  • to create a virtual environment
pip install django
Enter fullscreen mode Exit fullscreen mode
  • install django
pip install djangorestframework Markdown django-filter
Enter fullscreen mode Exit fullscreen mode
  • install django rest framework
django-admin startproject api
Enter fullscreen mode Exit fullscreen mode
  • start a django project

  • change directory to api/api

  • open settings.py

  • under installed apps

  • add the following lines to the end of the list

"rest_framework",
"rest_framework.authtoken"

Enter fullscreen mode Exit fullscreen mode

change directory to the root api

python manage.py migrate
Enter fullscreen mode Exit fullscreen mode
python manage.py runserver
Enter fullscreen mode Exit fullscreen mode

Discussion

pic
Editor guide