我在下面的模板中得到了这个错误
{% for post in post_queryset %}
                <div class="card-body">
                  <div class="date">{{ post.created_date }}</div>
                  <div class="title">
                    {{ post.text }}
                    {{ post.slug }}
                    <a href="{% url 'editPost' post.slug %}" ><i class="fa fa-edit"></i></a>
                    <a onClick="delete_post('{{post.slug}}','{{post_id}}')"><i class="fa fa-trash-o"></i></a>
                  </div>
                </div>
{% endfor %}我得到了这一行的错误
<a href="{% url 'editPost' post.slug %}" ><i class="fa fa-edit"></i></a>我在该行前面显示了{{ post.slug }},并对链接行进行了注释,以确保post.slug有一些内容。看来post.slug有有效的弹状体信息。
我还试着只传递一些字符串,而不是像下面这样传递post.slug。
<a href="{% url 'editPost' 'some_string' %}" ><i class="fa fa-edit"></i></a>我的urls.py如下所示
path('editPost/<postslug>/',views.editPost, name='editPost')有人能帮我找出错误吗?
发布于 2019-12-07 06:14:24
我得到了错误,因为在所有的帖子中,有一个帖子有空的弹格字段,这是导致错误的原因。
https://stackoverflow.com/questions/59223328
复制相似问题