summaryrefslogtreecommitdiff
path: root/django/template
diff options
context:
space:
mode:
authorNick Pope <nick@nickpope.me.uk>2021-04-22 16:55:59 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2022-07-23 12:36:21 +0200
commit4d4bf55e0ea849476f7e3abfeb018c338f18a9b4 (patch)
tree3eef7f8e90252c2f4f2c7ca9a07992af005e1744 /django/template
parent2fac0a18081dcc77fc860c801e5d727dc90435b3 (diff)
Fixed #33864 -- Deprecated length_is template filter.
Diffstat (limited to 'django/template')
-rw-r--r--django/template/defaultfilters.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/django/template/defaultfilters.py b/django/template/defaultfilters.py
index 46334791c6..7a5b28d159 100644
--- a/django/template/defaultfilters.py
+++ b/django/template/defaultfilters.py
@@ -2,6 +2,7 @@
import random as random_module
import re
import types
+import warnings
from decimal import ROUND_HALF_UP, Context, Decimal, InvalidOperation
from functools import wraps
from inspect import unwrap
@@ -11,6 +12,7 @@ from urllib.parse import quote
from django.utils import formats
from django.utils.dateformat import format, time_format
+from django.utils.deprecation import RemovedInDjango51Warning
from django.utils.encoding import iri_to_uri
from django.utils.html import avoid_wrapping, conditional_escape, escape, escapejs
from django.utils.html import json_script as _json_script
@@ -611,6 +613,11 @@ def length(value):
@register.filter(is_safe=False)
def length_is(value, arg):
"""Return a boolean of whether the value's length is the argument."""
+ warnings.warn(
+ "The length_is template filter is deprecated in favor of the length template "
+ "filter and the == operator within an {% if %} tag.",
+ RemovedInDjango51Warning,
+ )
try:
return len(value) == int(arg)
except (ValueError, TypeError):