Answer the question
In order to leave comments, you need to log in
How to change only one field in the database?
Good day. I want to make a view counter, but there was a problem.
def post(request, pk):
post = Post.objects.get(pk = pk)
post.count += 1
post.save()
return render(request, 'myblog/single.html', {'post': post})
Answer the question
In order to leave comments, you need to log in
post.save(update_fields=["count"]), but better as Sergei Tikhonov said
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question