Django views should return a Web response. For example here you could raise Http404. There is a shortcut use you use, that does what you want:

Replace the whole try/except block with 

`deleted_invite = get_object_or_404(Invite, pk=invite_pk, inviter=profile)` 

https://docs.djangoproject.com/en/dev/topics/http/shortcuts/#get-object-or-404