LoginSignup
0
0

More than 3 years have passed since last update.

Django: テンプレートのコメント内でおこるNoReverseMatch

Last updated at Posted at 2020-08-20

Djangoのテンプレート内においてコメントを使用している際、

post_detail.html
<!--
{% if object.author == user %}
<a href="{% url 'blog:post-update' object.id%}">Update</a>
<a href="{% url 'blog:post-delete' object.id %}">Delte</a>
{% endif %}
-->

のようにコメント内で記述したurl内に'blog:url名'のようにネームスペース名に言及した行があり、そのネームスペースが存在しない/一致しない場合にNoReverseMatchを起こす。

コメントで括った中にネームスペースが存在していてもエラーを起こすというのは予想外だったためハマりました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0