From 68b7c5c8ae6ad6e42ae9f0d073615c3505084851 Mon Sep 17 00:00:00 2001 From: shagi Date: Fri, 1 Jul 2022 09:20:43 +0200 Subject: [PATCH] Allow setting form id or class on base_form.html --- gas/templates/gas/base_form.html | 5 ++++- gas/views.py | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/gas/templates/gas/base_form.html b/gas/templates/gas/base_form.html index 6157ecf..24d21b2 100644 --- a/gas/templates/gas/base_form.html +++ b/gas/templates/gas/base_form.html @@ -4,7 +4,10 @@ {% load form_tags %} {% block content %} -
{% csrf_token %} + {% csrf_token %} {% if is_popup %} {% endif %} diff --git a/gas/views.py b/gas/views.py index 4dfa0aa..19f6721 100644 --- a/gas/views.py +++ b/gas/views.py @@ -201,6 +201,7 @@ class GASCreateView(GASMixin, CreateView): is_popup = "_popup" in self.request.GET ctx.update({ 'is_popup': is_popup, + 'form_id': 'main-form', }) return ctx @@ -220,6 +221,13 @@ class GASUpdateView(GASMixin, UpdateView): """ Same as Django's UpdateView, defined only for completeness. """ template_name = 'gas/base_form.html' + def get_context_data(self, **kwargs): + ctx = super().get_context_data(**kwargs) + ctx.update({ + 'form_id': 'main-form', + }) + return ctx + class GASDeleteView(GASMixin, DeleteView): template_name = "gas/delete_confirmation.html"