Skip to content

Instantly share code, notes, and snippets.

@kezabelle
Last active February 2, 2018 09:02
Show Gist options
  • Save kezabelle/33a7f41643fc3e70da9452971e1e91a4 to your computer and use it in GitHub Desktop.
Save kezabelle/33a7f41643fc3e70da9452971e1e91a4 to your computer and use it in GitHub Desktop.
something like this maybe. for xref on #django
class Goaway(View):
def dispatch(self, request, *args, **kwargs):
try:
resp = super(Goaway, self).dispatch(request, *args, **kwargs)
except Http404 as e:
return HttpResponseRedirect("/")
def get_object(self, *args, **kwargs):
obj = super(Goaway, self).get_object(*args, **kwargs)
if obj.account_id != self.request.user.account_id:
raise Http404("oof")
return obj
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment