#31484: Possibility to provide additional Context to Render a FlatPage
-------------------------------------+-------------------------------------
Reporter: thaxy | Owner: nobody
Type: New | Status: new
feature |
Component: | Version:
contrib.flatpages | Keywords: flatpage context
Severity: Normal | template render
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-------------------------------------+-------------------------------------
Hello,
In one of my projects, I am using the Django flatpages app/feature. This
worked fine so far but I have stumbled across a use case where I want to
{% include %} another template within the template of my flatpage. The
included template requires additional context data to work correctly.
The current implementation of the render function of the flatpage doesn't
allow the developer to add additional context data other than the flatpage
itself. (see:
https://github.com/django/django/blob/master/django/contrib/flatpages/views.py#L69).
One solution could be to allow additional `**kwargs` to be passed to the
render_flatpage function eventually being used to call the template.render
function.
Is this worth thinking about? In my opinion, this could be an improvement
- that's why I am writing to you. I could also try to create a PR
according to the guidelines if you think this is an improvement.
Some code to illustrate the problem:
**urls.py:**
{{{
path('texte/', views.flatpage, {'url': '/texte/'}, name='texte')
}}}
**texte.html:**
{{{
{% extends 'base.html' %}
{% block content %}
<div class="content">
{{ flatpage.content }}
</div>
{% include 'texte/uebersicht.html' %}
{% endblock content %}
}}}
**texte/uebersicht.html:**
{{{
<ul>
{% for p in prosa %} <!-- prosa is a queryset -->
<li>
<a href="{% url 'prosa' p.slug %}">{{ p }}</a>
</li>
{% empty %}
keine inhalte gefunden
{% endfor %}
</ul>
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/31484>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/048.2764963b98559b5b849436a2d29e531e%40djangoproject.com.