From 7ff173d9c714b904a8ee8bd94f304d5dccc9c213 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Ho=CC=88rler?= Date: Sun, 14 Jan 2018 23:38:10 +0100 Subject: [PATCH] yess! --- django/didgeridoo/currencies/views.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/django/didgeridoo/currencies/views.py b/django/didgeridoo/currencies/views.py index f7fbe23..5e9b496 100644 --- a/django/didgeridoo/currencies/views.py +++ b/django/didgeridoo/currencies/views.py @@ -12,8 +12,15 @@ from django.http import JsonResponse def currency_update(request): # https://simpleisbetterthancomplex.com/tutorial/2016/08/29/how-to-work-with-ajax-request-with-django.html - currency = request.POST.get('currency_update', None) - data = ExchangeRate.objects.values('exchange_rate_to_chf').latest() + if request.method == 'GET': + print('its get method') + else: + print('its not get method') + currency = request.GET.get('currency', None) + data = ExchangeRate.objects.filter( + name__name=currency).values( + 'exchange_rate_to_chf').latest( + 'date__date') print('currency: ', currency, 'data: ', data) return JsonResponse(data)