1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Introduced the render_json template filter

This commit is contained in:
Jeremy Stretch
2018-06-28 10:49:52 -04:00
parent c13e4858d7
commit b952ec73ce
4 changed files with 12 additions and 6 deletions

View File

@@ -1,6 +1,7 @@
from __future__ import unicode_literals
import datetime
import json
from django import template
from django.utils.safestring import mark_safe
@@ -46,6 +47,14 @@ def gfm(value):
return mark_safe(html)
@register.filter()
def render_json(value):
"""
Render a dictionary as formatted JSON.
"""
return json.dumps(value, indent=4, sort_keys=True)
@register.filter()
def model_name(obj):
"""