【发布时间】:2023-03-28 05:51:01
【问题描述】:
views.py
def post_share(request, post_id):
post = get_object_or_404(Post,id=post_id)
sent = False
return render(request, 'mains/post_share.html', {'post':post,'sent':sent})
urls.py
path('post_share/<int:post_id>',views.post_share,name='post_share'),
show_more.html
<p><a href="{% url 'mains:post_share' post.id %}">Share this post</a></p>
def __str__(self):
return self.post_title
当我点击 分享这篇文章(链接)在 share_more.html Reverse for 'post_share' with arguments '('',)' not found .尝试了 1 种模式:['post_share/(?P
【问题讨论】:
-
将
posts更改为post -
@minglyu 我已经改了。但仍然出现错误。
-
你确定post_share在
mainsapp的urls.py中吗? -
是的,我 100% 确定。有没有发现什么错误?
-
@Progam 你在重复这个错误,我猜你上次也遇到了同样的问题,检查我下面的答案,努力练习,仔细阅读文档,多注意代码。
标签: html django django-views django-forms django-templates