From 8e8132da7c716cb6cb0436035595988d42fc9fcb Mon Sep 17 00:00:00 2001 From: shaikhmudassir Date: Sun, 15 Oct 2023 23:53:37 +0530 Subject: [PATCH] TypeError: JSON object must not be list resolved --- leads/views.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/leads/views.py b/leads/views.py index 228c2e8c4..8ef27d312 100644 --- a/leads/views.py +++ b/leads/views.py @@ -80,12 +80,12 @@ def get_context_data(self, **kwargs): queryset = queryset.filter(source=params.get("source")) if params.getlist("assigned_to"): queryset = queryset.filter( - assigned_to__id__in=json.loads(params.get("assigned_to")) + assigned_to__id__in=params.get("assigned_to") ) if params.get("status"): queryset = queryset.filter(status=params.get("status")) if params.get("tags"): - queryset = queryset.filter(tags__in=json.loads(params.get("tags"))) + queryset = queryset.filter(tags__in=params.get("tags")) if params.get("city"): queryset = queryset.filter(city__icontains=params.get("city")) if params.get("email"): @@ -165,7 +165,7 @@ def post(self, request, *args, **kwargs): lead_obj = serializer.save(created_by=request.profile.user , org=request.profile.org) if data.get("tags",None): - tags = json.loads(data.get("tags")) + tags = data.get("tags") for t in tags: tag = Tags.objects.filter(slug=t.lower()) if tag.exists(): @@ -176,7 +176,7 @@ def post(self, request, *args, **kwargs): if data.get("contacts",None): obj_contact = Contact.objects.filter( - id__in=json.loads(data.get("contacts")), org=request.profile.org + id__in=data.get("contacts"), org=request.profile.org ) lead_obj.contacts.add(*obj_contact) @@ -195,12 +195,12 @@ def post(self, request, *args, **kwargs): attachment.save() if data.get("teams",None): - teams_list = json.loads(data.get("teams")) + teams_list = data.get("teams") teams = Teams.objects.filter(id__in=teams_list, org=request.profile.org) lead_obj.teams.add(*teams) if data.get("assigned_to",None): - assinged_to_list = json.loads(data.get("assigned_to")) + assinged_to_list = data.get("assigned_to") profiles = Profile.objects.filter( id__in=assinged_to_list, org=request.profile.org ) @@ -235,7 +235,7 @@ def post(self, request, *args, **kwargs): account_object.tags.add(tag) if data.get("assigned_to",None): - assigned_to_list = json.loads(data.getlist("assigned_to")) + assigned_to_list = data.getlist("assigned_to") recipients = assigned_to_list send_email_to_assigned_user.delay( recipients, @@ -438,7 +438,7 @@ def put(self, request, pk, **kwargs): ) lead_obj.tags.clear() if params.get("tags"): - tags = json.loads(params.get("tags")) + tags = params.get("tags") # for t in tags: # tag,_ = Tags.objects.get_or_create(name=t) # lead_obj.tags.add(tag) @@ -475,13 +475,13 @@ def put(self, request, pk, **kwargs): lead_obj.teams.clear() if params.get("teams"): - teams_list = json.loads(params.get("teams")) + teams_list = params.get("teams") teams = Teams.objects.filter(id__in=teams_list, org=request.profile.org) lead_obj.teams.add(*teams) lead_obj.assigned_to.clear() if params.get("assigned_to"): - assinged_to_list = json.loads(params.get("assigned_to")) + assinged_to_list = params.get("assigned_to") profiles = Profile.objects.filter( id__in=assinged_to_list, org=request.profile.org ) @@ -516,7 +516,7 @@ def put(self, request, pk, **kwargs): account_object.tags.add(tag) if params.get("assigned_to"): # account_object.assigned_to.add(*params.getlist('assigned_to')) - assigned_to_list = json.loads(params.get("assigned_to")) + assigned_to_list = params.get("assigned_to") recipients = assigned_to_list send_email_to_assigned_user.delay( recipients,