Ich möchte ein int, das an die Vorlage über die URL übergeben wird, aber es besagt, dass die str
Funktion nicht definiert ist.casting ints zu str in Jinja2
Wie kann ich das umgehen?
Hier ist mein Code:
{% extends "base.html" %}
{% block content %}
{% for post in posts %}
{% set year = post.date.year %}
{% set month = post.date.month %}
{% set day = post.date.day %}
{% set p = str(year) + '/' + str(month) + '/' + str(day) + '/' + post.slug %}
<h3>
<a href="{{ url_for('get_post', ID=p) }}">
{{ post.title }}
</a>
</h3>
<p>{{ post.content }}</p>
{% else: %}
There's nothing here, move along.
{% endfor %}
{% endblock %}
Das hat mich nur umgehauen. Jinja2 wird immer toller, wenn ich damit arbeite. – vectorfrog