Package django :: Package shortcuts
[hide private]
[frames] | no frames]

Package shortcuts

source code

This module collects helper functions and classes that "span" multiple levels of MVC. In other words, these functions/classes introduce controlled coupling for convenience's sake.

Functions [hide private]
 
render_to_response(*args, **kwargs)
Returns a HttpResponse whose content is filled with the result of calling django.template.loader.render_to_string() with the passed arguments.
source code
 
_get_queryset(klass)
Returns a QuerySet from a Model, Manager, or QuerySet.
source code
 
get_object_or_404(klass, *args, **kwargs)
Uses get() to return an object, or raises a Http404 exception if the object does not exist.
source code
 
get_list_or_404(klass, *args, **kwargs)
Uses filter() to return a list of objects, or raise a Http404 exception if the list is empty.
source code

Imports: loader, HttpResponse, Http404, Manager, QuerySet


Function Details [hide private]

_get_queryset(klass)

source code 

Returns a QuerySet from a Model, Manager, or QuerySet. Created to make get_object_or_404 and get_list_or_404 more DRY.

get_object_or_404(klass, *args, **kwargs)

source code 

Uses get() to return an object, or raises a Http404 exception if the object does not exist.

klass may be a Model, Manager, or QuerySet object. All other passed arguments and keyword arguments are used in the get() query.

Note: Like with get(), an MultipleObjectsReturned will be raised if more than one object is found.

get_list_or_404(klass, *args, **kwargs)

source code 

Uses filter() to return a list of objects, or raise a Http404 exception if the list is empty.

klass may be a Model, Manager, or QuerySet object. All other passed arguments and keyword arguments are used in the filter() query.