Skip to main content
Join the official 2020 Python Developers SurveyStart the survey!

add some feature for django view and request

Project description

  1. parse request body when request method is PUT, PATCH.
  2. support json request body.
  3. add expcetion handle for CBV(Class Based View)
  4. add permission check for CBV


$: pip install django_improved_view


from django_improved_view import exceptions, permissions
from django_improved_view.response import APIResponse
from django_improved_view.views import APIView
from django_improved_view.permissions import BasePermission

class BasicAuthRequiredError(exceptions.APIException):
    ERROR_CODE = 10000

class TokenRequired(BasePermission):
    def __call__(self):
        if not self.request.headers.get('Authorization'):
            raise BasicAuthRequiredError(user_hint='basic auth required')

class PermissionView(APIView):
    method_perms = {'POST': [TokenRequired]}

    def post(self, request):
        return APIResponse.ok({})


$: pytest tests

Project details

Release history Release notifications | RSS feed

This version


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for django-improved-view, version 1.0
Filename, size File type Python version Upload date Hashes
Filename, size django_improved_view-1.0-py3-none-any.whl (19.7 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size django_improved_view-1.0.tar.gz (16.2 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page