Django - Удаление дубликата из конечной точки API
Я разработал микросервис, где я получаю JSON из конечной точки и могу отобразить его в API, но я получаю повторяющиеся данные снова и снова для каждого id.
Я получаю JSON данные с localhost:8000 и хочу отобразить их на текущем localhost:7000. Я сделал несколько ошибок, но не смог найти, где я ошибаюсь. Я застрял здесь
views.py
class filterlistView(APIView):
def get(self, request):
filter_list = Userbase.objects.all()
# serializer = UserSerializer(filter_list, many=True)
# return Response(serializer.data)
return Response([self.formatfilter(filter) for filter in filter_list])
def formatfilter(self, post):
table_data= requests.get('http://127.0.0.1:1500/api/').json()
# return render(request, 'home.html',{'table_data':table_data})
return {
'id':post.id,
'Payment_Term':post.Payment_Term,
'Netdue_Date':post.Netdue_Date,
'Predicted_Paid_days':post.Predicted_Paid_days,
'PBK_Desc':post.PBK_Desc,
'Vendor_Name':post.Vendor_Name,
'Reference':post.Reference,
'company_code':post.company_code,
'Area':post.Area,
'country':post.country,
'table_data':table_data,
}
вывод:
{
"id": 1,
"Payment_Term": "demo2",
"Netdue_Date": "2021-10-20",
"Predicted_Paid_days": "2021-10-20",
"PBK_Desc": "sf",
"Vendor_Name": "AB",
"Reference": "AB",
"company_code": "1074",
"Area": "GCR",
"country": "CEE",
"table_data": [
{
"id": 1,
"stage": "Stage3 Train/Stage4 Test",
"region": "NORTH AMERICA",
"area": "US",
"country": "US",
"VendorName": "FOXLINK INTERNATIONAL INC",
"PBK_Desc": "Free for payment"
},
{
"id": 2,
"stage": "Stage3 Train/Stage4 Test",
"region": "NORTH AMERICA",
"area": "US",
"country": "US",
"VendorName": "FOXLINK INTERNATIONAL INC",
"PBK_Desc": "Free for payment"
},
]
},
{
"id": 2,
"Payment_Term": "3434",
"Netdue_Date": "2021-10-20",
"Predicted_Paid_days": "34",
"PBK_Desc": "sfsd",
"Vendor_Name": "fdsdf",
"Reference": "sdfsd",
"company_code": "1154",
"Area": "WE",
"country": "Germany",
"table_data": [
{
"id": 1,
"stage": "Stage3 Train/Stage4 Test",
"region": "NORTH AMERICA",
"area": "US",
"country": "US",
"VendorName": "FOXLINK INTERNATIONAL INC",
"PBK_Desc": "Free for payment"
},
{
"id": 2,
"stage": "Stage3 Train/Stage4 Test",
"region": "NORTH AMERICA",
"area": "US",
"country": "US",
"VendorName": "FOXLINK INTERNATIONAL INC",
"PBK_Desc": "Free for payment"
},
]
}
]