@register.simple_tag
def treebeard_js():
    path = get_static_url()
    js_file = urljoin(path, 'treebeard/treebeard-admin.js')
    jquery_ui = urljoin(path, 'treebeard/jquery-ui-1.8.5.custom.min.js')

    # Jquery UI is needed to call disableSelection() on drag and drop so
    # text selections arent marked while dragging a table row
    # http://www.lokkju.com/blog/archives/143
    TEMPLATE = (
        '<script type="text/javascript" src="{}"></script>'
        '<script type="text/javascript" src="{}"></script>'
        '<script>'
            '(function($){{jQuery = $.noConflict(true);}})(django.jQuery);'
        '</script>'
        '<script type="text/javascript" src="{}"></script>')
    return format_html(
        TEMPLATE, "jsi18n", mark_safe(js_file), mark_safe(jquery_ui))
Template tag to print out the proper <script/> tag to include a custom .js
dataset/ETHPy150Open tabo/django-treebeard/treebeard/templatetags/admin_tree.py/treebeard_js