This module is a collection of helper classes generally used in view functions/classes. All the shortcuts are available
in the module django.shortcuts
.
render
Params:
Shortcut for:
There is also render_to_response, the only difference is that it does not pass the request to the context.
redirect
Params:
Returns an HttpResponseRedirect
(or HttpResponsePermanentRedirect
) to the appropriate URL for the arguments passed.
The arguments could be:
- A model: the model’s
get_absolute_url()
function will be called. - A view name, possibly with arguments:
urls.reverse()
will be used to reverse-resolve the name. - A URL, which will be used as-is for the redirect location.
Shortcut for:
See more in this post about the redirect function.
get_object_or_404
Params:
Shortcut for:
get_list_or_404
Params:
Shortcut for:
resolve_url
This one is actually used by the redirect shortcut. It will do basically the same thing, except to perform the actual redirect.
Params:
The arguments could be:
- A model: the model’s
get_absolute_url()
function will be called. - A view name, possibly with arguments:
urls.reverse()
will be used to reverse-resolve the name. - A URL, which will be returned as-is.