From 1d3b8d44b473c11c78743e6cb4631bbc20bdc9b1 Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Sat, 14 Dec 2024 01:41:26 +0000 Subject: [PATCH] More form layout chnages for Django v5 --- core/forms.py | 4 ++-- core/views/caves.py | 5 ++--- templates/editcave.html | 15 ++++++++++----- templates/html_editor_scripts_css.html | 5 ++++- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/core/forms.py b/core/forms.py index 88f8345..822afa5 100644 --- a/core/forms.py +++ b/core/forms.py @@ -64,7 +64,7 @@ class CaveForm(ModelForm): # widget=forms.TextInput(attrs={"placeholder": "see example below"}) # ) kataster_code = forms.CharField(required=False, - label = "Kataster code, see below", + label = "Kataster code, see bottom of page", widget=forms.TextInput(attrs={"placeholder": "see example below"}) ) # underground_centre_line = forms.CharField( @@ -87,7 +87,7 @@ class CaveForm(ModelForm): length = forms.CharField(required=False, label="Length (m)", widget=forms.TextInput(attrs={"placeholder": "usually blank"})) depth = forms.CharField(required=False, label="Depth (m)", widget=forms.TextInput(attrs={"placeholder": "usually blank"})) extent = forms.CharField(required=False, label="Extent (m)", widget=forms.TextInput(attrs={"placeholder": "usually blank"})) - subarea = forms.CharField(required=False, label="Subarea", widget=forms.TextInput(attrs={"placeholder": "usually blank, archaic"})) + subarea = forms.CharField(required=False, label="Subarea (do not use for new caves)", widget=forms.TextInput(attrs={"placeholder": "usually blank, archaic"})) #cave_slug = forms.CharField() diff --git a/core/views/caves.py b/core/views/caves.py index 6c11519..56f0d36 100644 --- a/core/views/caves.py +++ b/core/views/caves.py @@ -521,14 +521,13 @@ def edit_cave(request, path="", slug=None): form = CaveForm(instance=cave, initial={'cave_slug': cave.slug()}) else: form = CaveForm() - # The way formsets are rendered chnaged between Django 4 and Django 5 + + # The way formsets are rendered changed between Django 4 and Django 5 major, _, _, _, _ = django.VERSION if major < 5: tabletype = "table" else: tabletype = "div" - print(f"edit_cave(): returning render() with tabletype={tabletype} {django.VERSION} ") - return render( request, diff --git a/templates/editcave.html b/templates/editcave.html index 05fc243..28fcccc 100644 --- a/templates/editcave.html +++ b/templates/editcave.html @@ -54,14 +54,19 @@ and these same fields appear in the alternative file upload process as described {% endif %} {% include 'html_editor_pop_ups.html' %} - -

{{message}}

+

{{message}}

+
{% csrf_token %} - {% if tabletype == 'table' %}{% else %}
{% endif %} + {% if tabletype == 'table' %}
{% endif %} {{ form }} - {% if tabletype == 'table' %}
{% else %}{% endif %} + {% if tabletype == 'table' %}{% endif %}

diff --git a/templates/html_editor_scripts_css.html b/templates/html_editor_scripts_css.html index d16cdaf..b67c915 100644 --- a/templates/html_editor_scripts_css.html +++ b/templates/html_editor_scripts_css.html @@ -32,7 +32,10 @@ z-index: 20; } - .HTMLarea { width:100%;} + .HTMLarea { + width:100%; # width:130%; + # margin-left: -235px + } .popup-overlay.active { /*displays pop-up when "active" class is present*/