From 4cbb662fb45f51f31622525f8afb338aa92d07b0 Mon Sep 17 00:00:00 2001 From: Andreas Zweili Date: Sun, 4 Feb 2018 20:03:09 +0100 Subject: [PATCH] fix the currency selector in the details view --- django/didgeridoo/webshop/views.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/django/didgeridoo/webshop/views.py b/django/didgeridoo/webshop/views.py index 32d5446..4460ed2 100644 --- a/django/didgeridoo/webshop/views.py +++ b/django/didgeridoo/webshop/views.py @@ -132,10 +132,14 @@ def article_details(request, article_id): currencies_form = CurrenciesForm(request.POST) print("currencies_form") if currencies_form.is_valid(): - selection = currencies_form.cleaned_data['currencies'] - request.session['currency'] = selection.id - currency_name = ExchangeRate_name.objects.get( - id=selection.id) + cf = currencies_form.cleaned_data + if cf['currencies']: + selection = cf['currencies'] + request.session['currency'] = selection.id + currency_name = ExchangeRate_name.objects.get( + id=selection.id) + else: + request.session['currency'] = None # hier wird der Artikel in den Wahrenkorb transferiert: if 'amount' in request.POST: