python

How to Recursively Convert Django Model to Dict

In this article we will look at how to create your own recursive serializer in Django without using the Django Rest Framework Sometimes when working with Django, we may have some data that we want to serialize (convert to JSON) but we do not have the option of using the serializers that come with Django Rest Framework. The data can also take the same form for many cases and writing a new serializer for all of those cases can be tedious and repetitive.
Read more >

How to Create Custom Permission Class in Django

Permissions can be a hustle to deal with when developing an api. Suppose we have a number of api views and endpoints where the access permissions are very similar to one another with only slight variations.. We could create different permission classes with the slight changes that fit the specific endpoint’s needs. That works, but that involves a lot of repetition and duplicated code that can be hard to update later down the line.
Read more >