diff options
| author | Claude Paroz <claude@2xlibre.net> | 2013-07-05 19:33:19 +0200 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2013-07-05 19:33:19 +0200 |
| commit | 1116df0751cc0d5862590b08adfffe7bacd6bf43 (patch) | |
| tree | c27ece7732a22fd9a4df1ed4867872d77729403f | |
| parent | 7442eb1a242ecf9d186d4e7de1b94e360e04782d (diff) | |
Deprecate usage of boolean value for widget attributes
Django 1.7 will loudly warn when widget attributes are assigned
boolean values. In Django 1.8, False will mean attribute is not
present while True will mean attribute present without value.
Refs #20684.
| -rw-r--r-- | django/forms/util.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/django/forms/util.py b/django/forms/util.py index 0a73320f83..3c7724900a 100644 --- a/django/forms/util.py +++ b/django/forms/util.py @@ -1,5 +1,7 @@ from __future__ import unicode_literals +import warnings + from django.conf import settings from django.utils.html import format_html, format_html_join from django.utils.encoding import force_text, python_2_unicode_compatible @@ -21,6 +23,11 @@ def flatatt(attrs): The result is passed through 'mark_safe'. """ + if [v for v in attrs.values() if v is True or v is False]: + warnings.warn( + 'The meaning of boolean values for widget attributes will change in Django 1.8', + DeprecationWarning + ) return format_html_join('', ' {0}="{1}"', sorted(attrs.items())) @python_2_unicode_compatible |
