Django REST API

Code Snippets used when building REST API with Django Rest Framework. Will be updated on the go.

This is a quick lookup blog post that comes in handly when building api's with django rest framework.

Installing packages : Below is a list of packages that you will mostly require when building api with Django REST Framework.

requirements.txt
Django
djangorestframework
channels
channels
daphne
Pillow
djangorestframework-simplejwt

Adding django rest framework to the installed apps config in settings.

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'rest_framework',
]

Adding django rest framework simple jwt auth class to settings.

REST_FRAMEWORK = {
    'DEFAULT_AUTHENTICATION_CLASSES': (
        'rest_framework_simplejwt.authentication.JWTAuthentication',
        'rest_framework.authentication.SessionAuthentication',
    )
}