【发布时间】:2022-11-25 05:02:17
【问题描述】:
我为我的 django 应用程序创建了一个 HTML 日历。但是,当我将它添加到我的其中一个模板时,它会将它添加到我的页脚下方。我不明白为什么会这样。
{% extends "bf_app/app_bases/app_base.html" %}
{% block main %}
{% include "bf_app/overviews/overview_nav.html" %}
<div class="flex justify-between mx-10">
<a href="{% url 'calendar_overview_context' previous_year previous_month %}">< {{ previous_month_name }}</a>
<a href="{% url 'calendar_overview_context' next_year next_month %}">{{ next_month_name }} ></a>
</div>
<div class="grid grid-cols-1 md:grid-cols-3 px-4">
<table>
<thead>
<tr>
<th class="text-left">Transaction</th>
<th class="text-left">Amount</th>
<th class="text-left">Date</th>
</tr>
</thead>
{% for transaction, tally in monthly_budget.items %}
<tr>
<td>{{ transaction }}</td>
<td class="{% if tally|last == "IN" %}text-green-700{% else %}text-red-700{% endif %}">
{{ tally|first|floatformat:2 }}
</td>
<td>{{ transaction.next_date|date:"D, d M, Y" }}</td>
</tr>
{% endfor %}
</table>
</div>
<div>
{{ calendar }}
</div>
{% endblock %}
我几乎遵循了本教程: https://www.huiwenteo.com/normal/2018/07/24/django-calendar.html
有什么我想念的吗?据我了解,这应该像我创建的其他所有内容一样位于页脚之上。
编辑:
这似乎是导致问题的“mark_safe”模块。我试过使用{{ calendar|safe }},这也会产生同样的问题。
【问题讨论】:
-
您将页脚放在
"bf_app/app_bases/app_base.html"的什么位置,前提是
标签: python html django django-templates