This commit is contained in:
iriska-gri committed 2023-10-05 08:10:05 +03:00
1 parent c7add1d73a
commit 6f53b7d716
3 files changed
+18 -16

No files matched your search

+2 -8
View File
@@ -46,7 +46,6 @@ class NewsAPIView(ListAPIView):
result.append(a)
return Response(result)
# "author":model_to_dict(DictEmployee.objects.values("fio").using('user_directory').get(login=k.author.username))
def post(self, request):
print(request.data, '-----------------------------------------')
if 'scores' in request.data:
@@ -63,14 +62,9 @@ class NewsAPIView(ListAPIView):
if 'text' in request.data:
CommentNews.objects.create(news_id=request.data['news'], author=self.request.user, text=request.data['text'])
print(request.data['news'])
back = {'news': request.data['news'], 'comment': ({"text":y.text, "cdate":y.cdate,
"author": {'id':y.author.id,
'familyname':'Гришина',
'name':'Ирина',
'parentname':'Сергеевна'
}} for y in CommentNews.objects.filter(news_id=request.data['news']))}
# familyname + ' ' + name.name[0] + '.' + name.parentname, [{"score":y.text, "news":request.data['news']} for y in CommentNews.objects.filter(news_id=request.data['news'])]
"author":model_to_dict(DictEmployee.objects.using('user_directory').get(login=y.author.username))
} for y in CommentNews.objects.filter(news_id=request.data['news']))}
return Response(back)