modify article API return
This commit is contained in:
parent
c9b7683238
commit
8aa4fa2dce
1 changed files with 17 additions and 3 deletions
|
@ -1338,13 +1338,27 @@ def history_json(request):
|
|||
opegroups_list.append(opegroup_dict)
|
||||
return JsonResponse({ 'opegroups': opegroups_list })
|
||||
|
||||
|
||||
@teamkfet_required
|
||||
def kpsul_articles_data(request):
|
||||
articles = (
|
||||
Article.objects
|
||||
.values('id', 'name', 'price', 'stock', 'category_id', 'category__name')
|
||||
.filter(is_sold=True))
|
||||
return JsonResponse({ 'articles': list(articles) })
|
||||
.filter(is_sold=True)
|
||||
.select_related('category'))
|
||||
articlelist = []
|
||||
|
||||
for article in articles:
|
||||
articlelist.append({
|
||||
'id': article.id,
|
||||
'name': article.name,
|
||||
'price': article.price,
|
||||
'stock': article.stock,
|
||||
'category': {
|
||||
'id': article.category.id,
|
||||
'name': article.category.name,
|
||||
}
|
||||
})
|
||||
return JsonResponse(articlelist, safe=False)
|
||||
|
||||
@teamkfet_required
|
||||
def history(request):
|
||||
|
|
Loading…
Reference in a new issue