简体   繁体   English

错误 - (django-taggit) - 'post_list_by_tag' 与参数 '('',)' 未找到

[英]Error - (django-taggit) - 'post_list_by_tag' with arguments '('',)' not found

studying django, can't find a solution.学习django,找不到解决办法。 added tags and the site gives an error studying django, can't find a solution.添加了标签,该站点在学习 django 时出现错误,找不到解决方案。 added tags and the site gives an error添加了标签,网站出现错误

list.html列表.html

        <p class="tags">
            Tags:
            {% for tag in post.tags.all %}
                <a href="{% url 'blog:post_list_by_tag' tag.slug %}">
                    {{ tag.name }}
                </a>
                {% if not forloop.last %}, {% endif %}
            {% endfor %}
        </p>
        ```


urls.py

    from django.urls import path
from . import views

app_name = 'blog'
urlpatterns = [
    # post views
    path('', views.post_list, name='post_list'),

    # path('', views.PostListView.as_view(), name='post_list'),
    path('<int:year>/<int:month>/<int:day>/<slug:post>/',views.post_detail,name='post_detail'),
    path('<int:post_id>/share/', views.post_share, name='post_share'),
    path('tag/<slug:tag_slug>/', views.post_list, name='post_list_by_tag'),
]

通过删除所有以前创建的没有标签的帖子解决了这个问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM