当前位置: 首页>>代码示例>>Python>>正文


Python UserSerializer.is_valid方法代码示例

本文整理汇总了Python中serializers.UserSerializer.is_valid方法的典型用法代码示例。如果您正苦于以下问题:Python UserSerializer.is_valid方法的具体用法?Python UserSerializer.is_valid怎么用?Python UserSerializer.is_valid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在serializers.UserSerializer的用法示例。


在下文中一共展示了UserSerializer.is_valid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: post

# 需要导入模块: from serializers import UserSerializer [as 别名]
# 或者: from serializers.UserSerializer import is_valid [as 别名]
 def post(self, request, format=None):
     serializer = UserSerializer(data=request.DATA)
     if serializer.is_valid():
         #serializer.data
         message = "from User2"
         return Response({"message": message, "data": serializer.data})
     return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
开发者ID:eduStack,项目名称:edx_siteapi,代码行数:9,代码来源:views.py

示例2: post

# 需要导入模块: from serializers import UserSerializer [as 别名]
# 或者: from serializers.UserSerializer import is_valid [as 别名]
 def post(self,request, format=None):        
     data = request.DATA
     graph = facebook.GraphAPI(data['token'])
     profile = graph.get_object("me")
     picture = graph.get_connections("me", "picture")
     objUser = {}
     objUser['first_name'] = profile['first_name']
     objUser['last_name'] = profile['last_name']
     objUser['email'] = profile['email']
     objUser['username'] = profile['id']
     objUser['is_active'] = True
     objProfile = {}
     objProfile['access_token'] = data['token']
     objProfile['profile_picture'] = picture['url']
     objProfile['gender'] = profile['gender']
     objUser['user_profile'] = objProfile
     user = UserSerializer()
     serializer = UserSerializer(data=objUser)        
     try:
         userobj = User.objects.get(username=objUser['username'])
         return Response(objUser, status=status.HTTP_200_OK)
     except User.DoesNotExist:
         if serializer.is_valid():
             serializer.save()      
             return Response(serializer.data, status=status.HTTP_201_CREATED)
         return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
开发者ID:eSketchers,项目名称:socialquote,代码行数:28,代码来源:views.py

示例3: put

# 需要导入模块: from serializers import UserSerializer [as 别名]
# 或者: from serializers.UserSerializer import is_valid [as 别名]
 def put(self, request, pk, format=None):
     user = self.get_object(pk)
     serializer = UserSerializer(user, data=request.DATA)
     if serializer.is_valid():
         serializer.save()
         return Response(serializer.data)
     return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
开发者ID:erigones,项目名称:api_openvpn,代码行数:9,代码来源:views.py

示例4: create_user

# 需要导入模块: from serializers import UserSerializer [as 别名]
# 或者: from serializers.UserSerializer import is_valid [as 别名]
def create_user(request):
    data = request.data
    serializer = UserSerializer(data=data)
    if serializer.is_valid():
        serializer.save()
        return Response({'message': 'Created'})
    return Response(serializer.errors)
开发者ID:ZandekA,项目名称:buddhasoft_task,代码行数:9,代码来源:views.py

示例5: post

# 需要导入模块: from serializers import UserSerializer [as 别名]
# 或者: from serializers.UserSerializer import is_valid [as 别名]
 def post(self, request):
     serializer = UserSerializer(data=request.DATA)
     if serializer.is_valid():
         serializer.save()
         return Response(serializer.data, status=201)
     else:
         return Response(serializer.errors, status=400)
开发者ID:nabilmania,项目名称:frikr,代码行数:9,代码来源:api.py

示例6: post

# 需要导入模块: from serializers import UserSerializer [as 别名]
# 或者: from serializers.UserSerializer import is_valid [as 别名]
 def post(self, request):
     serializer = UserSerializer(data=request.DATA)
     if serializer.is_valid(): # los serializer funcionan como los djangoforms, así que hay que validarlo
         serializer.save()     # guardamos en la base de datos el nuevo usuario
         return Response(serializer.data, status=status.HTTP_201_CREATED)
     else:
         return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
开发者ID:enrimr,项目名称:django_frikr_example,代码行数:9,代码来源:api.py

示例7: createUser

# 需要导入模块: from serializers import UserSerializer [as 别名]
# 或者: from serializers.UserSerializer import is_valid [as 别名]
 def createUser(self, request):
     data = JSONParser.parse(request)
     serializer = UserSerializer(data=data)
     if serializer.is_valid():
         serializer.save()
         return JSONResponse(serializer.data, status=201)
     return JSONResponse(serializer.errors, status=400)
开发者ID:SCuvanov,项目名称:Babybook_API,代码行数:9,代码来源:Views.py

示例8: post

# 需要导入模块: from serializers import UserSerializer [as 别名]
# 或者: from serializers.UserSerializer import is_valid [as 别名]
 def post(self, request):
     serializer = UserSerializer(data=request.DATA)  # en lugar request.POST
     if serializer.is_valid():
         serializer.save()
         return Response(serializer.data, status=status.HTTP_201_CREATED)
     else:
         return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
开发者ID:juandetoro,项目名称:Frikr,代码行数:9,代码来源:api.py

示例9: post

# 需要导入模块: from serializers import UserSerializer [as 别名]
# 或者: from serializers.UserSerializer import is_valid [as 别名]
 def post(self, request, format=None):
     #Si existe el usuario dar mensaje de error de que ya existe.
     serializer = UserSerializer(data=request.DATA)
     if serializer.is_valid():
         serializer.save()
         return Response(serializer.data, status=status.HTTP_201_CREATED)
     return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
开发者ID:rbenvos,项目名称:shop_list,代码行数:9,代码来源:api.py

示例10: put

# 需要导入模块: from serializers import UserSerializer [as 别名]
# 或者: from serializers.UserSerializer import is_valid [as 别名]
 def put(self, request, id, format=None):
     snippet = self.get_object(id=id)
     serializer = UserSerializer(snippet, data=request.data)
     if serializer.is_valid():
         serializer.save()
         return Response(serializer.data)
     return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
开发者ID:kazixma,项目名称:djangorestframeworktutorial,代码行数:9,代码来源:views.py

示例11: post

# 需要导入模块: from serializers import UserSerializer [as 别名]
# 或者: from serializers.UserSerializer import is_valid [as 别名]
 def post(self, request, format=None):
     queryset = Logistics_user.objects.all()
     serializer = UserSerializer(data=request.data)
     if serializer.is_valid():
         serializer.save()
         return Response(serializer.data, status=status.HTTP_201_CREATED)
     return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
开发者ID:Rahulkr204,项目名称:SEN-project,代码行数:9,代码来源:views.py

示例12: put

# 需要导入模块: from serializers import UserSerializer [as 别名]
# 或者: from serializers.UserSerializer import is_valid [as 别名]
 def put(self, request, pk, format=None):
     user = Logistics_user.objects.get(pk=pk)
     serializer = UserSerializer(user, data=request.data)#, many=True, context={'request': request})
     if serializer.is_valid():
         serializer.save()
         return Response(serializer.data)
     return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
开发者ID:Rahulkr204,项目名称:SEN-project,代码行数:9,代码来源:views.py

示例13: patch

# 需要导入模块: from serializers import UserSerializer [as 别名]
# 或者: from serializers.UserSerializer import is_valid [as 别名]
 def patch(self, request):
    serialized = UserSerializer(data=request.DATA)
    if serialized.is_valid():
        serialized.save()
        return Response(status=status.HTTP_205_RESET_CONTENT)
    else:
        return Response(serialized.errors, status=status.HTTP_400_BAD_REQUEST)
开发者ID:sirius9,项目名称:restauth_login_test,代码行数:9,代码来源:views.py

示例14: get

# 需要导入模块: from serializers import UserSerializer [as 别名]
# 或者: from serializers.UserSerializer import is_valid [as 别名]
 def get(self, request, *args, **kw):
     ip = kw.get('pk')
     kw['request'] = request
     ip_details_request = IPDetails(ip)
     result = DetailsSerializer(ip_details_request)
     if not request.session.get('alienvaultid'):
         traffic_details_request = TrafficDetails(request, ip)
         user = UserSerializer(traffic_details_request)
         user_serializer = UserSerializer(
             data=JSONParser().parse(
                 BytesIO(JSONRenderer().render(user.data))
             )
         )
         user_serializer.is_valid()
         user_serializer.save()
     response = Response(result.data, status=status.HTTP_200_OK)
     return response
开发者ID:cgjonesdev,项目名称:alienvault,代码行数:19,代码来源:views.py

示例15: post

# 需要导入模块: from serializers import UserSerializer [as 别名]
# 或者: from serializers.UserSerializer import is_valid [as 别名]
 def post(self, request):
     serialized = UserSerializer(data=request.data)
     if serialized.is_valid():
         serialized.save()
         Player.objects.create(user_id=serialized.data['id'])
         return Response(serialized.data, status=status.HTTP_201_CREATED)
     else:
         return Response(serialized._errors, status=status.HTTP_400_BAD_REQUEST)
开发者ID:blstream,项目名称:ut-arena,代码行数:10,代码来源:views.py


注:本文中的serializers.UserSerializer.is_valid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。