[Answered ]-How to prevent users from editing or deleting other user posts ? Django

2👍

Check if the current user is the original author of the post and take appropriate action if not:

def post_edit(request, pk):
   post = get_object_or_404(Post, pk=pk)
   if post.user != request.user:
      raise Http404  # or similar
   # ...

Ideally, you would also check that in the template and show the form to the author and not to anybody else.

Leave a comment