django 1.6 url标记错误
我的app1应用程序有问题:django 1.6 url标记错误,django,django-1.6,Django,Django 1.6,我的app1应用程序有问题: Reverse for 'app1.views.add_content' with arguments '('',)' and keyword arguments '{}' not found. 1 pattern(s) tried: ['/add-content/(\\d+)/$'] 观点 网址 在模板中,这一行有错误 <a id="add_content" class="button" href="{% url 'app1.views.add_conte
Reverse for 'app1.views.add_content' with arguments '('',)' and keyword arguments '{}' not found. 1 pattern(s) tried: ['/add-content/(\\d+)/$']
观点
网址
在模板中,这一行有错误
<a id="add_content" class="button" href="{% url 'app1.views.add_content' pk %}">Add New Content</a>
有什么问题吗?哦,我把添加内容错读为添加类别 你的错误在这里:
{% url 'app1.views.add_content' pk %}
应该是这样的:
{% url 'app1.views.add_content' category.pk %}
您的模板中似乎没有定义pk。我没有看到您在render_to_响应中将pk传递给模板。也许你的意思是category.pk或类似的东西?我尝试依次添加:category.pk、category.id、category\u id,但在你的url中有相同的错误:urlr'^/add content/?P\d+/$',app1.views.add\u content',name='add\u content',将您的解决方案添加到URL和上述所有使用的模板中,但对于“app1.views.add_content”和“arguments”“and keyword arguments”“{}”没有找到相同的errorReverse。已尝试1个模式:['/add content/?P\\d+/$']您没有传递任何参数,是否确实在模板中定义了类别?
{% url 'app1.views.add_content' pk %}
{% url 'app1.views.add_content' category.pk %}