Skip to content
Snippets Groups Projects
Commit 3c6c975a authored by Julian's avatar Julian
Browse files

Include request in the templatetag

parent 09951d81
Branches 602-pre-define-periodic-tasks
No related tags found
1 merge request!452Resolve "Provide request in DashboardWidget.get_context"
Pipeline #5416 passed
...@@ -3,10 +3,11 @@ from django.template import Library, loader ...@@ -3,10 +3,11 @@ from django.template import Library, loader
register = Library() register = Library()
@register.simple_tag @register.simple_tag(takes_context=True)
def include_widget(widget) -> dict: def include_widget(context, widget) -> dict:
"""Render a template with context from a defined widget.""" """Render a template with context from a defined widget."""
template = loader.get_template(widget.get_template()) template = loader.get_template(widget.get_template())
context = widget.get_context() request = context["request"]
context = widget.get_context(request)
return template.render(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