o***@gmail.com
2018-07-30 11:51:58 UTC
Hi All my project on django rest framework
i am getting json response as raw model class
[
{
"id": 1,
"client_name": "google",
"client_logo": "oo"
}
]
but i want to add success message in json response like this?
{
"success":"data fetch successfully"
[
{
"id": 1,
"client_name": "google",
"client_logo": "oo"
}
]
}
how can i do this??
here is all the details
my model is like this
class Client1(models.Model):
client_name = models.CharField(max_length=100, unique =True)
client_logo = models.CharField(max_length=300, null=True)
seraliazer class is
class ClientSerailizers(serializers.ModelSerializer):
class Meta:
model = Client1
fields = ('id', 'client_name', 'client_logo')
and view is
class SnippetList(APIView):
def get(self, request, *args, **kwargs):
client = Client1.objects.all()
success = {"response": "success"}
serializer = ClientSerailizers(client, many=True)
return Response(serializer.data, status=status.HTTP_201_CREATED)
s
i am getting json response as raw model class
[
{
"id": 1,
"client_name": "google",
"client_logo": "oo"
}
]
but i want to add success message in json response like this?
{
"success":"data fetch successfully"
[
{
"id": 1,
"client_name": "google",
"client_logo": "oo"
}
]
}
how can i do this??
here is all the details
my model is like this
class Client1(models.Model):
client_name = models.CharField(max_length=100, unique =True)
client_logo = models.CharField(max_length=300, null=True)
seraliazer class is
class ClientSerailizers(serializers.ModelSerializer):
class Meta:
model = Client1
fields = ('id', 'client_name', 'client_logo')
and view is
class SnippetList(APIView):
def get(self, request, *args, **kwargs):
client = Client1.objects.all()
success = {"response": "success"}
serializer = ClientSerailizers(client, many=True)
return Response(serializer.data, status=status.HTTP_201_CREATED)
s
--
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.