I want to update and delete post and it is happening but now I want users to Update and delete a post only created by them. Strating from delete this is my delete function
def delete_post(request , id):
post=Post.objects.get(pk=id)
if request.user==post.user: '''I think this if is not true even when the post is created by the same user who is requesting to delete it.'''
post.delete()
print("ok")
return redirect("home")
Now when click on delete post it returns to home page but the post remains same.it doesn't delete the post.