Skip to content
Snippets Groups Projects
Verified Commit cf848bdb authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

Add template tag for better widget inclusion

parent 75a060c3
No related branches found
No related tags found
1 merge request!142Implement core functionality for dashboard widgets
Pipeline #763 failed
{% extends 'core/base.html' %}
{% load i18n static %}
{% load i18n static dashboard %}
{% block browser_title %}{% blocktrans %}Home{% endblocktrans %}{% endblock %}
......@@ -27,9 +27,7 @@
<div class="row" id="live_load">
{% for widget in widgets %}
<div class="col s12 m12 l6 xl4">
{% with widget as d_widget %}
{% include widget.template %}
{% endwith %}
{% include_widget widget %}
</div>
{% endfor %}
</div>
......
from django.template import Context, Library, loader
register = Library()
@register.simple_tag
def include_widget(widget) -> dict:
""" Render a template with context from a defined widget """
template = loader.get_template(widget.get_template())
context = Context(widget.get_context())
return template.render(context)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment