You don't do it this way -- as in, don't look for an exception that
corresponds precisely to a particular HTTP status code and except Django
to handle it automatically for you. Http404 is a very special case in
Django of an exception that corresponds to an HTTP response. You should
be raising more semantic exceptions in your code that will, at output
time, be mapped to the appropriate HttpResponse with status code set
(something like HttpResponseForbidde).
In this case, it sounds like you want to be raising something like
django.core.exceptions.PermissionDenied in your code and then catching
that in your view(s).
Hoewver, it's not all hard work. In this particular case (only) --
raising PermissionDenied -- if your code does nothing, the
request/response handling code in Django will convert it to a very
simple HttpResponseForbidden response for you. That's an odd case,
though. Normally, if you raise an exception, you'll have to handle it
yourself and convert it to the appropriate HTTP status code, since only
you really know what the right status code is for your exception paths.
Regards,
Malcolm
--
How many of you believe in telekinesis? Raise my hand...
http://www.pointy-stick.com/blog/