我想投一個int通過url傳遞給模板,但它說str
函數沒有被定義。鑄造inja到strin in Jinja2
我該如何解決這個問題?
這裏是我的代碼:
{% 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 %}
這只是讓我失望。當我使用它時,Jinja2變得越來越棒。 – vectorfrog 2015-03-24 14:46:42