Just an idea: You can modify urls.py to allow only `all`, `future`, `past` and `custom` for `period` (instead of `\w+`). That way you won't have to `raise Http404` in this function. Not that what you've done is bad.