not finished AJAX request for currencies
This commit is contained in:
parent
e765a999c6
commit
19af243c4f
|
@ -4,4 +4,7 @@ from currencies.views import currencies, CurrencyUpdate
|
|||
|
||||
urlpatterns = [
|
||||
url(r'^currencies/$', currencies),
|
||||
url(r'^ajax/CurrencyUpdate/$',
|
||||
CurrencyUpdate,
|
||||
name='CurrencyUpdate'),
|
||||
]
|
||||
|
|
|
@ -7,17 +7,18 @@ from currencies.models import (ExchangeRate,
|
|||
ExchangeRate_name)
|
||||
from currencies import exchange_rates
|
||||
from currencies.forms import CurrencyForm
|
||||
from django.http import JsonResponse
|
||||
|
||||
|
||||
def CurrencyUpdate(request):
|
||||
if request.method == 'POST':
|
||||
currency_form = CurrencyForm
|
||||
assert False
|
||||
else:
|
||||
currency_form = CurrencyForm
|
||||
assert False
|
||||
return render(request,
|
||||
{'currency_form': currency_form})
|
||||
assert False
|
||||
currency = request.GET.get('CurrencyUpdate', None)
|
||||
data = {
|
||||
'currency': ExchangeRate_name.objects.filter(
|
||||
name=currency)
|
||||
}
|
||||
return JsonResponse(data)
|
||||
|
||||
|
||||
def currencies(request):
|
||||
# this function fetches the data from exchange_rates.py
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
$("#id_currency").change(function () {
|
||||
var currency = $(this).val();
|
||||
$.ajax({
|
||||
url: '/ajax/CurrencyUpdate/',
|
||||
data: {
|
||||
'currency': currency
|
||||
},
|
||||
dataType: 'json',
|
||||
success: function (data) {
|
||||
if (data.is_taken) {
|
||||
alert("es pop auf! --dies kommt von: static/js/app.js--.");
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
|
@ -11,6 +11,10 @@ urlpatterns = [
|
|||
views.articles_in_category,
|
||||
name='category'),
|
||||
url('^', include('django.contrib.auth.urls')),
|
||||
url(r'^profile/$', views.profile, name='profile'),
|
||||
url(r'^registration/$', views.registration, name='registration'),
|
||||
url(r'^profile/$',
|
||||
views.profile,
|
||||
name='profile'),
|
||||
url(r'^registration/$',
|
||||
views.registration,
|
||||
name='registration'),
|
||||
]
|
||||
|
|
|
@ -11,6 +11,7 @@ from webshop.models import (Article,
|
|||
Picture)
|
||||
from webshop.forms import RegistrationForm
|
||||
|
||||
|
||||
# Create your views here.
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue