Skip to content

Instantly share code, notes, and snippets.

View RossIV's full-sized avatar

Ross Lindsay RossIV

View GitHub Profile
@synotna
synotna / FieldPermissionsMixin
Created July 15, 2015 13:01
Field permissions mixin for Django Rest Framework
class FieldPermissionsMixin(object):
"""
A Serializer mixin for controlling which fields are included based on user permissions
Usage:
class MySerializer(FieldPermissionsMixin, serializers.ModelSerializer):
class Meta:
model = MyModel
field_permissions = {
'field': ['app.permission'],