URL을 통해 템플릿에 전달 된 int를 캐스팅하려고하지만, str
함수가 정의되지 않았다고 말합니다.Jinja2에서 str에 ints를 캐스팅합니다.
어떻게이 문제를 해결할 수 있습니까? 당신은 join
을 사용할 수 있습니다
{% 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