當前位置: 首頁>>代碼示例>>Python>>正文


Python UserSerializer.save方法代碼示例

本文整理匯總了Python中serializers.UserSerializer.save方法的典型用法代碼示例。如果您正苦於以下問題:Python UserSerializer.save方法的具體用法?Python UserSerializer.save怎麽用?Python UserSerializer.save使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在serializers.UserSerializer的用法示例。


在下文中一共展示了UserSerializer.save方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: put

# 需要導入模塊: from serializers import UserSerializer [as 別名]
# 或者: from serializers.UserSerializer import save [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

示例2: post

# 需要導入模塊: from serializers import UserSerializer [as 別名]
# 或者: from serializers.UserSerializer import save [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: create_user

# 需要導入模塊: from serializers import UserSerializer [as 別名]
# 或者: from serializers.UserSerializer import save [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

示例4: patch

# 需要導入模塊: from serializers import UserSerializer [as 別名]
# 或者: from serializers.UserSerializer import save [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

示例5: post

# 需要導入模塊: from serializers import UserSerializer [as 別名]
# 或者: from serializers.UserSerializer import save [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: createUser

# 需要導入模塊: from serializers import UserSerializer [as 別名]
# 或者: from serializers.UserSerializer import save [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

示例7: post

# 需要導入模塊: from serializers import UserSerializer [as 別名]
# 或者: from serializers.UserSerializer import save [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

示例8: put

# 需要導入模塊: from serializers import UserSerializer [as 別名]
# 或者: from serializers.UserSerializer import save [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

示例9: post

# 需要導入模塊: from serializers import UserSerializer [as 別名]
# 或者: from serializers.UserSerializer import save [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: post

# 需要導入模塊: from serializers import UserSerializer [as 別名]
# 或者: from serializers.UserSerializer import save [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

示例11: put

# 需要導入模塊: from serializers import UserSerializer [as 別名]
# 或者: from serializers.UserSerializer import save [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

示例12: post

# 需要導入模塊: from serializers import UserSerializer [as 別名]
# 或者: from serializers.UserSerializer import save [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

示例13: post

# 需要導入模塊: from serializers import UserSerializer [as 別名]
# 或者: from serializers.UserSerializer import save [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

示例14: put

# 需要導入模塊: from serializers import UserSerializer [as 別名]
# 或者: from serializers.UserSerializer import save [as 別名]
     def put(self,request,pk):

         user = get_object_or_404(User,pk=pk)
         serializer = UserSerializer(user,data=request.DATA)

         if serializer.is_valid():
             serializer.save()
             return Response(serializer.data,status=status.HTTP_200_OK)
         else:
             return Response(serializer.errors,status=status.HTTP_400_BAD_REQUEST)
開發者ID:navlin07,項目名稱:Django-Python,代碼行數:12,代碼來源:api.py

示例15: post

# 需要導入模塊: from serializers import UserSerializer [as 別名]
# 或者: from serializers.UserSerializer import save [as 別名]
 def post(self, request):
     # Para crear un usuario
     # Hay que pasar request.DATA en vez de request.POST
     serializer = UserSerializer(data=request.DATA)
     if serializer.is_valid():
         serializer.save()
         return Response(serializer.data, status=status.HTTP_201_CREATED)
     else:
         # Algo ha ido mal
         return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
開發者ID:DuB0k,項目名稱:Friker,代碼行數:12,代碼來源:api.py


注:本文中的serializers.UserSerializer.save方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。