Can `load_backend` or `get_user` raise `KeyError`s? If not, then this `except` can be narrowed to just cover the first two lines. Also, if it were me, I'd probably just check the user that I got back from `get_user` for `None` right away, and return a 404 immediately, rather than setting the user to `AnonymousUser` and then checking for it immediately.

I guess this is all assuming that get_user won't return AnonymousUser itself.