Changeset 5744
- Timestamp:
- 07/21/07 22:09:24 (1 year ago)
- Files:
-
- django/trunk/django/shortcuts/__init__.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/shortcuts/__init__.py
r5511 r5744 1 # This module collects helper functions and classes that "span" multiple levels 2 # of MVC. In other words, these functions/classes introduce controlled coupling 3 # for convenience's sake. 1 """ 2 This module collects helper functions and classes that "span" multiple levels 3 of MVC. In other words, these functions/classes introduce controlled coupling 4 for convenience's sake. 5 """ 4 6 5 7 from django.template import loader … … 8 10 9 11 def render_to_response(*args, **kwargs): 12 """ 13 Return a HttpResponse whose content is filled with the result of calling 14 django.template.loader.render_to_string() with the passed arguments. 15 """ 10 16 return HttpResponse(loader.render_to_string(*args, **kwargs)) 11 17 load_and_render = render_to_response # For backwards compatibility. 12 18 13 19 def get_object_or_404(klass, *args, **kwargs): 20 """ 21 Use get() to return an object, or raise a Http404 exception if the object 22 does not exist. 23 24 klass may be a Model, Manager, or QuerySet object. All other passed 25 arguments and keyword arguments are used in the get() query. 26 27 Note: Like with get(), an AssertionError will be raised if more than one 28 object is found. 29 """ 14 30 if isinstance(klass, Manager): 15 31 manager = klass … … 23 39 24 40 def get_list_or_404(klass, *args, **kwargs): 41 """ 42 Use filter() to return a list of objects, or raise a Http404 exception if 43 the list is empty. 44 45 klass may be a Model, Manager, or QuerySet object. All other passed 46 arguments and keyword arguments are used in the filter() query. 47 """ 25 48 if isinstance(klass, Manager): 26 49 manager = klass
