mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-28 08:59:54 +03:00
Documented templatetags.rest_framework:add_nested_class
This commit is contained in:
parent
0dac98d215
commit
1a4f48027d
|
@ -283,6 +283,12 @@ def schema_links(section, sec_key=None):
|
|||
|
||||
@register.filter
|
||||
def add_nested_class(value):
|
||||
"""
|
||||
Check if value is instance of `dict` or `list` of `dict` objects return the `nested` class
|
||||
Othervise return '' (blank string)
|
||||
Usage
|
||||
{{ value|add_nested_class }}
|
||||
"""
|
||||
if isinstance(value, dict):
|
||||
return 'class=nested'
|
||||
if isinstance(value, list) and any([isinstance(item, (list, dict)) for item in value]):
|
||||
|
|
Loading…
Reference in New Issue
Block a user