diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 3b191bcc6d..85d3d7f2b0 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -50,6 +50,7 @@ Changelog * Fix: Added file handling to support custom user add/edit forms with images/files (Eraldo Energy) * Fix: Placeholder text in modeladmin search now uses the correct template variable (Adriaan Tijsseling) * Fix: Fixed bad SQL syntax for updating URL paths on Microsoft SQL Server (Jesse Legg) + * Fix: Added workaround for Django 1.10 bug https://code.djangoproject.com/ticket/27037 causing forms with file upload fields to fail validation (Matt Westcott) 1.5.3 (18.07.2016) diff --git a/docs/releases/1.6.rst b/docs/releases/1.6.rst index b676a44aab..8739799e76 100644 --- a/docs/releases/1.6.rst +++ b/docs/releases/1.6.rst @@ -79,6 +79,7 @@ Bug fixes * Added file handling to support custom user add/edit forms with images/files (Eraldo Energy) * Placeholder text in modeladmin search now uses the correct template variable (Adriaan Tijsseling) * Fixed bad SQL syntax for updating URL paths on Microsoft SQL Server (Jesse Legg) + * Added workaround for Django 1.10 bug https://code.djangoproject.com/ticket/27037 causing forms with file upload fields to fail validation (Matt Westcott) Upgrade considerations diff --git a/wagtail/contrib/modeladmin/templates/modeladmin/create.html b/wagtail/contrib/modeladmin/templates/modeladmin/create.html index 7a88fc811e..b384679db2 100644 --- a/wagtail/contrib/modeladmin/templates/modeladmin/create.html +++ b/wagtail/contrib/modeladmin/templates/modeladmin/create.html @@ -1,5 +1,5 @@ {% extends "wagtailadmin/base.html" %} -{% load i18n %} +{% load i18n wagtailadmin_tags %} {% block titletag %}{{ view.get_meta_title }}{% endblock %} @@ -19,7 +19,7 @@ {% include "wagtailadmin/shared/header.html" with title=view.get_page_title subtitle=view.get_page_subtitle icon=view.header_icon tabbed=1 merged=1 %} {% endblock %} -
+ {% csrf_token %} {% block form %}{{ edit_handler.render_form_content }}{% endblock %} diff --git a/wagtail/contrib/settings/templates/wagtailsettings/edit.html b/wagtail/contrib/settings/templates/wagtailsettings/edit.html index aca58e6eef..98188e700f 100644 --- a/wagtail/contrib/settings/templates/wagtailsettings/edit.html +++ b/wagtail/contrib/settings/templates/wagtailsettings/edit.html @@ -1,5 +1,5 @@ {% extends "wagtailadmin/base.html" %} -{% load i18n %} +{% load i18n wagtailadmin_tags %} {% block titletag %}{% blocktrans %}Editing {{ setting_type_name}} - {{ instance }}{% endblocktrans %}{% endblock %} {% block bodyclass %}menu-settings{% endblock %} {% block content %} @@ -26,7 +26,7 @@ - + {% csrf_token %} {{ edit_handler.render_form_content }} diff --git a/wagtail/wagtailadmin/templates/wagtailadmin/generic/create.html b/wagtail/wagtailadmin/templates/wagtailadmin/generic/create.html index 4e3c1ee7ec..137c20254a 100644 --- a/wagtail/wagtailadmin/templates/wagtailadmin/generic/create.html +++ b/wagtail/wagtailadmin/templates/wagtailadmin/generic/create.html @@ -1,5 +1,5 @@ {% extends "wagtailadmin/base.html" %} -{% load i18n %} +{% load i18n wagtailadmin_tags %} {% block titletag %}{{ view.page_title }}{% endblock %} @@ -7,7 +7,7 @@ {% include "wagtailadmin/shared/header.html" with title=view.page_title icon=view.header_icon %} - + {% csrf_token %} {% block hidden_fields %} diff --git a/wagtail/wagtailadmin/templates/wagtailadmin/generic/edit.html b/wagtail/wagtailadmin/templates/wagtailadmin/generic/edit.html index d6679c9430..8b96735cec 100644 --- a/wagtail/wagtailadmin/templates/wagtailadmin/generic/edit.html +++ b/wagtail/wagtailadmin/templates/wagtailadmin/generic/edit.html @@ -1,5 +1,5 @@ {% extends "wagtailadmin/base.html" %} -{% load i18n %} +{% load i18n wagtailadmin_tags %} {% block titletag %}{{ view.page_title }} {{ view.get_page_subtitle }}{% endblock %} @@ -8,7 +8,7 @@ {% include "wagtailadmin/shared/header.html" with title=view.page_title subtitle=view.get_page_subtitle icon=view.header_icon %}
- + {% csrf_token %} {% block hidden_fields %} diff --git a/wagtail/wagtailadmin/templates/wagtailadmin/pages/create.html b/wagtail/wagtailadmin/templates/wagtailadmin/pages/create.html index a1c0e0f2cb..9fd9687ed1 100644 --- a/wagtail/wagtailadmin/templates/wagtailadmin/pages/create.html +++ b/wagtail/wagtailadmin/templates/wagtailadmin/pages/create.html @@ -17,7 +17,7 @@
- + {% csrf_token %} {{ edit_handler.render_form_content }} diff --git a/wagtail/wagtailadmin/templates/wagtailadmin/pages/edit.html b/wagtail/wagtailadmin/templates/wagtailadmin/pages/edit.html index 602912805e..ceccf72ab9 100644 --- a/wagtail/wagtailadmin/templates/wagtailadmin/pages/edit.html +++ b/wagtail/wagtailadmin/templates/wagtailadmin/pages/edit.html @@ -24,7 +24,7 @@ - + {% csrf_token %} {{ edit_handler.render_form_content }} diff --git a/wagtail/wagtailadmin/templatetags/wagtailadmin_tags.py b/wagtail/wagtailadmin/templatetags/wagtailadmin_tags.py index 180ea3c671..41677d9c45 100644 --- a/wagtail/wagtailadmin/templatetags/wagtailadmin_tags.py +++ b/wagtail/wagtailadmin/templatetags/wagtailadmin_tags.py @@ -312,3 +312,17 @@ def message_tags(message): return level_tag else: return '' + + +@register.simple_tag +def novalidate_on_django_1_10(): + """ + Django 1.10 has a bug that breaks client-side validation on forms that include + prefilled file upload fields. This is due to be fixed in Django 1.10.1; as a + workaround, we apply this tag to disable client-side validation (using the + 'novalidate' attribute) on all forms with enctype="multipart/form-data". + """ + if django.VERSION >= (1, 10, 0) and django.VERSION < (1, 10, 1): + return 'novalidate' + else: + return '' diff --git a/wagtail/wagtaildocs/templates/wagtaildocs/chooser/chooser.html b/wagtail/wagtaildocs/templates/wagtaildocs/chooser/chooser.html index 155a00ae17..16fe22e9bc 100644 --- a/wagtail/wagtaildocs/templates/wagtaildocs/chooser/chooser.html +++ b/wagtail/wagtaildocs/templates/wagtaildocs/chooser/chooser.html @@ -1,4 +1,4 @@ -{% load i18n %} +{% load i18n wagtailadmin_tags %} {% trans "Choose a document" as choose_str %} {% include "wagtailadmin/shared/header.html" with title=choose_str tabbed=1 merged=1 icon="doc-full-inverse" %} @@ -28,7 +28,7 @@ {% if uploadform %}
- + {% csrf_token %}
{% if uploadform %}
- + {% csrf_token %}