again.
This commit is contained in:
parent
5e91470470
commit
c7d9e62f05
|
@ -1,10 +1,10 @@
|
|||
from django.conf.urls import url
|
||||
from currencies.views import currencies, CurrencyUpdate
|
||||
from currencies.views import currencies, currency_update
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^currencies/$', currencies),
|
||||
url(r'^ajax/CurrencyUpdate/$',
|
||||
CurrencyUpdate,
|
||||
name='CurrencyUpdate'),
|
||||
url(r'^ajax/currency_update/$',
|
||||
currency_update,
|
||||
name='currency_update'),
|
||||
]
|
||||
|
|
|
@ -10,11 +10,11 @@ from currencies.forms import CurrencyForm
|
|||
from django.http import JsonResponse
|
||||
|
||||
|
||||
def CurrencyUpdate(request):
|
||||
currency = request.GET.get('CurrencyUpdate', None)
|
||||
def currency_update(request):
|
||||
currency = request.GET.get('currency_update', None)
|
||||
data = {
|
||||
'currency': ExchangeRate_name.objects.get(
|
||||
currency).id
|
||||
'currency': ExchangeRate.objects.filter(
|
||||
name__name=currency).latest('date')
|
||||
}
|
||||
print('currency: ', currency, 'data: ', data)
|
||||
return JsonResponse(data)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
$("#CurrencyUpdate").change(function () {
|
||||
$("#currency_update").change(function () {
|
||||
var currency = $(this).val();
|
||||
$.ajax({
|
||||
url: '/ajax/CurrencyUpdate/',
|
||||
url: '/ajax/currency_update/',
|
||||
data: {
|
||||
'currency': currency
|
||||
},
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
</ul>
|
||||
<form action="" method="POST" novalidate>
|
||||
{% csrf_token %}
|
||||
<select name="CurrencyUpdate" id="CurrencyUpdate" onchange="this.form.submit()">
|
||||
<select name="currency_update" id="currency_update" onchange="this.form.submit()">
|
||||
<option value="CHF">CHF</option>
|
||||
<option value="USD">USD</option>
|
||||
<option value="GBP">GBP</option>
|
||||
|
|
Loading…
Reference in New Issue