我想从我的页面创建up-vote一个down-vote视图category_request,但是如何计算整数字段。应该由i+1或完成i-1?
def category_request_up_vote (request, pk):
category_request = get_object_or_404(CategoryRequests, pk=pk)
try:
if request.method == 'GET':
category_request.up_vote() << here i guess
messages.success(request, 'You have successfully Provided an Up-Vote for this Request')
return redirect('category_request_detail', pk=category_request.pk)
else:
messages.success(request, 'Uuups, something went wrong, please try again.')
return redirect('category_request_detail', pk=category_request.pk)
except Exception as e:
messages.warning(request, 'Uuups, something went wrong, please try again. Error {}'.format(e))
模型.py
...
up_vote = models.IntegerField(default=0)
down_vote = models.IntegerField(default=0)
...
我想我不必提及我是 Python/Django 的新手 ^^
不负相思意
杨__羊羊
相关分类