예제 #1
0
 def post(self, request, *args, **kwargs):
     serializer = self.serializer_class(data=request.data,
                                        context={'request': request})
     serializer.is_valid(raise_exception=True)
     user = serializer.validated_data['user']
     token, created = Token.objects.get_or_create(user=user)
     user_serializer = UserSelectSerializer(instance=user)
     details = user_serializer.data
     details.update(token=token.key)
     return Response(details)
예제 #2
0
파일: order.py 프로젝트: Boburbeck/alpha
 def to_representation(self, instance):
     self.fields['cashier'] = UserSelectSerializer()
     self.fields['client'] = ClientSelectSerializer()
     return super(OrderModelSerializer, self).to_representation(instance)
예제 #3
0
 def to_representation(self, instance):
     self.fields['category'] = CategorySelectSerializer()
     self.fields['creator'] = UserSelectSerializer()
     return super(ProductModelSerializer, self).to_representation(instance)
예제 #4
0
 def to_representation(self, instance):
     self.fields['creator'] = UserSelectSerializer()
     self.fields['product'] = ProductSelectSerializer()
     return super(SoldCostModelSerializer, self).to_representation(instance)
예제 #5
0
 def to_representation(self, instance):
     self.fields['client'] = ClientSelectSerializer()
     self.fields['stock'] = StockSelectSerializer()
     self.fields['created_by'] = UserSelectSerializer()
     return super(TransactionModelSerializer,
                  self).to_representation(instance)