Voglio eseguire il cast di un int che viene passato al modello tramite l'url, ma che la funzione str
non è definita.casting da Jinja2
Come aggirare questo?
Ecco il mio codice:
{% 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 %}
Questo mi ha fatto impazzire. Jinja2 diventa sempre più fantastico mentre lavoro con esso. – vectorfrog