ingredients = map(lambda food: food.to_json(), Food.objects.values_list('id', 'title').filter(title__icontains=name))
return JsonResponse(json.dumps(ingredients), safe=True)
def __str__(self):
return '{} - {}'.format(self.name_song, self.musician)
def get_document(request, file_link):
document = get_object_or_None(Document, link=file_link, users=request.user.id)
if document:
return serve(request,
path=document.document.name,
document_root=settings.USERS_DOCUMENT_ROOT)
return HttpResponse('Error!')