From 05b77b8845f4eddaa605e4b32729e5f72ba4320e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Ho=CC=88rler?= Date: Sun, 14 Jan 2018 17:13:41 +0100 Subject: [PATCH] unfinished part of currency dropdown --- django/didgeridoo/currencies/forms.py | 4 +- django/didgeridoo/currencies/urls.py | 2 - django/didgeridoo/currencies/views.py | 14 +++--- .../webshop/templates/webshop/base.html | 44 ++++++++++--------- 4 files changed, 35 insertions(+), 29 deletions(-) diff --git a/django/didgeridoo/currencies/forms.py b/django/didgeridoo/currencies/forms.py index 5acf450..f1df52d 100644 --- a/django/didgeridoo/currencies/forms.py +++ b/django/didgeridoo/currencies/forms.py @@ -3,5 +3,5 @@ from currencies.models import ExchangeRate_name class CurrencyForm(forms.Form): - currencies = forms.ModelChoiceField( - queryset=ExchangeRate_name.objects.all()) + currencies = forms.ModelChoiceField( + queryset=ExchangeRate_name.objects.all()) diff --git a/django/didgeridoo/currencies/urls.py b/django/didgeridoo/currencies/urls.py index 8b2dd1a..28801cf 100644 --- a/django/didgeridoo/currencies/urls.py +++ b/django/didgeridoo/currencies/urls.py @@ -4,6 +4,4 @@ from currencies.views import currencies, CurrencyUpdate urlpatterns = [ url(r'^currencies/$', currencies), - url(r'^/$', CurrencyUpdate.as_view(), - name='CurrencyUpdate'), ] diff --git a/django/didgeridoo/currencies/views.py b/django/didgeridoo/currencies/views.py index cc392ec..5af1837 100644 --- a/django/didgeridoo/currencies/views.py +++ b/django/didgeridoo/currencies/views.py @@ -9,11 +9,15 @@ from currencies import exchange_rates from currencies.forms import CurrencyForm -class CurrencyUpdate(UpdateView): - model = ExchangeRate_name - currency_form = CurrencyForm - template_name = 'webshop/base.html' - success_url = 'webshop/base.html' +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}) def currencies(request): # this function fetches the data from exchange_rates.py diff --git a/django/didgeridoo/webshop/templates/webshop/base.html b/django/didgeridoo/webshop/templates/webshop/base.html index a560c90..661fbae 100644 --- a/django/didgeridoo/webshop/templates/webshop/base.html +++ b/django/didgeridoo/webshop/templates/webshop/base.html @@ -34,27 +34,31 @@ HOME + +
+ {% csrf_token %} + +
-