I am writing an application using Django 1.9, Guardian and Django Rest Framework.
I am trying to add a new perm (view_group) to groups. This new perm will control what groups logged-in user can see when calling the backend. I am using DjangoObjectPermissions.
Apparently it seems very daunting to add view_group permission to django.contrib.auth.models.Group class. I was wondering if anybody has managed to do it. If so please let me see the solution.
This my models
from django.contrib.auth.models import Group as realGroup
from django.db import models
from guardian import shortcuts
from users.models import User
if not hasattr(realGroup, 'parent'):
field = models.ForeignKey(realGroup, blank=True, null=True, related_name='children')
field.contribute_to_class(realGroup, 'parent')
class Group(realGroup):
"""
This is a custom group.
"""
class Meta:
proxy = True
permissions = (("view_group", "Can view group"), )
I am getting this exception Content Type matching query does not exist. Although I was trying to hack it and add to the system.