wcs: fix |count query None queryset (#70955)

This commit is contained in:
Lauréline Guérin 2022-11-03 10:03:31 +01:00
parent a49ab97480
commit c5b89d13a2
No known key found for this signature in database
GPG Key ID: 1FAB9B9B4F93D473
2 changed files with 6 additions and 0 deletions

View File

@ -41,6 +41,8 @@ def access_control(queryset, user):
@register.filter
def count(queryset):
if queryset is None:
return 0
return queryset.count

View File

@ -235,6 +235,10 @@ def test_count(mock_send, context, nocache):
t = Template('{{ cards|objects:"foo"|count }}')
assert t.render(context) == "2"
context = Context({'foo': None})
t = Template('{{ foo|count }}')
assert t.render(context) == "0"
OPERATORS = [
('equal', 'eq'),