Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用Django restframework为从AbstractBaseUser继承的用户模型设置权限_Django_Django Models_Django Rest Framework_Django Authentication_Django Permissions - Fatal编程技术网

如何使用Django restframework为从AbstractBaseUser继承的用户模型设置权限

如何使用Django restframework为从AbstractBaseUser继承的用户模型设置权限,django,django-models,django-rest-framework,django-authentication,django-permissions,Django,Django Models,Django Rest Framework,Django Authentication,Django Permissions,让我们有一个我的用户模型的结构 BaseUser <- BusinessOwner <- Business Staff (BusinessOwner can create,update,delete BusinessStaff ) BaseUser <- Customer 我的观点.py class CreateBusinessOwnerView(mixins.ListModelMixin, mixins.CreateModelMixin,

让我们有一个我的用户模型的结构

BaseUser <- BusinessOwner <- Business Staff (BusinessOwner can create,update,delete BusinessStaff )
BaseUser <- Customer
我的观点.py

class CreateBusinessOwnerView(mixins.ListModelMixin,
              mixins.CreateModelMixin,
              generics.GenericAPIView):
    queryset = BusinessOwner.objects.all()
    serializer_class = CreateBusinessOwner

    def get(self, request, *args, **kwargs):
        return self.list(request, *args, **kwargs)

    def post(self, request, *args, **kwargs):
        return self.create(request, *args, **kwargs)

    def post_save(self, obj, created=False):
        if created:
            obj.set_password(obj.password)
            obj.save()
还有我的serializers.py

class CreateBusinessOwner(serializers.ModelSerializer):
    class Meta:
        model = BusinessOwner
        fields = ('email', 'password', 'first_name', 'last_name', 'business_name' ,'date_joined')
        read_only_fields = ('date_joined',)
谢谢你帮助我

class CreateBusinessOwner(serializers.ModelSerializer):
    class Meta:
        model = BusinessOwner
        fields = ('email', 'password', 'first_name', 'last_name', 'business_name' ,'date_joined')
        read_only_fields = ('date_joined',)