From 6a3c8c3ff340110960bf64dbfc31e526243f6616 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Tue, 21 Nov 2017 10:46:58 +0100 Subject: Custom forms: disable completly a form --- archaeological_operations/wizards.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'archaeological_operations/wizards.py') diff --git a/archaeological_operations/wizards.py b/archaeological_operations/wizards.py index fffe34ca7..24c1af45b 100644 --- a/archaeological_operations/wizards.py +++ b/archaeological_operations/wizards.py @@ -23,6 +23,7 @@ from django.conf import settings from django.core.exceptions import ObjectDoesNotExist from django.core.urlresolvers import reverse from django.db.models import Max +from django.http import Http404 from django.shortcuts import render from django.utils.translation import ugettext_lazy as _ @@ -149,7 +150,10 @@ class OperationWizard(Wizard): data = {} if not step: step = self.steps.current - form = self.get_form_list()[step] + try: + form = self.get_form_list()[step] + except KeyError: + raise Http404() # manage the dynamic choice of towns if step.startswith('towns') and hasattr(form, 'management_form'): data['TOWNS'] = self.get_towns() -- cgit v1.2.3