A Django Mixin capable of deserializing a request's body into python data
structures. It works for requests with Content-type either
application/json
or application/x-www-form-urlencoded
.
Tested in Python 2.7
and Python 3.2
against Django >= 1.5
.
pip install django-deserializer
Simply have your Class-Based View inherit from the
deserializer.mixins.DeserializationMixin
. From that point on, the view has
inherited the deserialize
method. When invoked, that method deserializes
and returns the request's body.
from deserializer.mixins import DeserializationMixin
from django.views.generic.base import View
class MyView(View, DeserializationMixin):
def post(self, request, *args, **kwargs):
body = self.deserialize()