+1 here

On 9/22/05, Adrian Holovaty <[EMAIL PROTECTED]> wrote:
>
> Here's a common pattern in views:
>
>     def foo_detail(request, some_lookup):
>         try:
>             f = foos.get_object(some_field__exact=some_lookup)
>         except foos.FooDoesNotExist:
>             raise Http404
>
> I propose a new helper function in django.core.extensions,
> get_or_404(), which would do this:
>
>     def foo_detail(request, some_lookup):
>         f = get_or_404(foos, some_field__exact=some_lookup)
>
> The function would raise Http404 if the object doesn't exist.
>
> This is a prime candidate for inclusion in django/core/extensions.py,
> which is where we put functions that "span" several layers of MVC.
>
> Thoughts?
>
> Adrian
>
> --
> Adrian Holovaty
> holovaty.com | djangoproject.com | chicagocrime.org
>


--
Paul Bowsher
IT Systems Developer
Simply Stuck Ltd

Reply via email to