I want to create a custom Django rest framework permission class by subclassing BasePermission, but I would also like it to be an abstract class. When doing so I get following error:
from abc import ABC, abstractmethod
from rest_framework.permissions import BasePermission
class CustomPermission(BasePermission, ABC):
def has_permission(self, request, view):
f1 = self.custom_func()
return f1 == 1
@abstractmethod
def custom_func(self):
...
Error:
TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases
Thanks
Update
Following also doesnt work. Generates same error:
class CustomPermission(BasePermission, ABC,metaclass=BasePermissionMetaclass):
...