【发布时间】:2019-08-18 10:25:20
【问题描述】:
我正在尝试编辑一个 html 页面,以便登录用户可以收藏/收藏video.id
这是 .html 文件
<td>
<form method='POST' action="{% url 'researcher_view_app:favourite_post' video.id %}">
{% csrf_token %}
<input type='hidden' name='video' value={{ video.id }}>
<button type='submit'>Bookmark</button>
</form>
</td>
这是 urls.py 文件
path('<int:fav_id>/favourite_post', views.favourite_post, name='favourite_post'),
这是 view.py 文件
def favourite_post(request, fav_id):
video = get_object_or_404(Video, id=fav_id)
if request.method == 'POST':
video.
return render(request, 'researcher_view_app/%s' % fav_id)
【问题讨论】:
-
谢谢你不加解释的投票者
-
您在此处存储“最喜欢”的机制是什么,另一个模型类?此问题中没有足够的信息来提供特定问题的答案。请添加足够的上下文,以便有人可以为您指出解决方案。
标签: django python-3.x django-models django-forms django-views