a guest Feb 20th, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def my_view(request, username):
  2.   user = get_object_or_404(User, username = username)
  3.   if user != request.user:
  4.     return HttpRequestForbidden()
  6. def get_object(self, queryset=None):
  7.     """ Hook to ensure object is owned by request.user. """
  8.     obj = super(MyDeleteView, self).get_object()
  9.     if not obj.owner == self.request.user:
  10.         raise Http404
  11.     return obj
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand