I have following response data
JavaScript
x
33
33
1
[
2
{
3
"id": 7,
4
"name": "Default Group",
5
"permissions": [
6
22,
7
24
8
]
9
},
10
{
11
"id": 10,
12
"name": "Another Group",
13
"permissions": [
14
1,
15
2,
16
22,
17
24
18
]
19
},
20
{
21
"id": 11,
22
"name": "New Group",
23
"permissions": [
24
10,
25
11,
26
12,
27
5,
28
6,
29
7,
30
8
31
]
32
}]
33
But I want to remove the dictionary whose id = 10 from the response data ,how can I do that ?
I have following lines of code..
JavaScript
1
10
10
1
class GetUserGroupList(APIView):
2
3
4
def post(self, request, *args, **kwargs):
5
6
groups = Group.objects.all()
7
serializer = GroupSerializer(groups, many=True)
8
9
return Response(serializer.data)
10
In serializers.py
JavaScript
1
6
1
class GroupSerializer(serializers.ModelSerializer):
2
3
class Meta:
4
model = Group
5
fields = ('id', 'name', 'permissions',)
6
Any help would be appreciated !!
Advertisement
Answer
What happens if you do something as following :
JavaScript
1
2
1
groups = Group.objects.exclude(id=10)
2