Ticket #2659: get_object_or_none.patch
File get_object_or_none.patch, 650 bytes (added by , 18 years ago) |
---|
-
django/shortcuts/__init__.py
10 10 return HttpResponse(loader.render_to_string(*args, **kwargs)) 11 11 load_and_render = render_to_response # For backwards compatibility. 12 12 13 def get_object_or_none(klass, *args, **kwargs): 14 try: 15 return klass._default_manager.get(*args, **kwargs) 16 except klass.DoesNotExist: 17 return None 18 13 19 def get_object_or_404(klass, *args, **kwargs): 14 20 try: 15 21 return klass._default_manager.get(*args, **kwargs)