views.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:clubnet 作者: mani-shailesh 项目源码 文件源码
def add_club(self, request, pk=None):
        """
        Collaborate with another Club in this project.
        """
        project = self.get_object()
        club_id = int(request.query_params.get('club', -1))

        if club_id == -1:
            raise rest_exceptions.ValidationError(
                'The request must contain a club!'
            )

        try:
            club = models.Club.objects.get(id=club_id)
        except models.Club.DoesNotExist:
            raise rest_exceptions.ValidationError(
                'The club does not exist!'
            )

        project.add_club(club)
        serializer = serializers.ProjectSerializer(project)
        return Response(serializer.data)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号