Ticket #7640: get_list_or_404.patch

File get_list_or_404.patch, 614 bytes (added by Kamu, 16 years ago)
  • django/shortcuts/__init__.py

    diff --git a/django/shortcuts/__init__.py b/django/shortcuts/__init__.py
    index 1cece7c..eafdd0c
    a b def get_list_or_404(klass, *args, **kwargs):  
    5656    arguments and keyword arguments are used in the filter() query.
    5757    """
    5858    queryset = _get_queryset(klass)
    59     obj_list = list(queryset.filter(*args, **kwargs))
    60     if not obj_list:
     59    obj_list = queryset.filter(*args, **kwargs)
     60    if obj_list.count() == 0:
    6161        raise Http404('No %s matches the given query.' % queryset.model._meta.object_name)
    6262    return obj_list
Back to Top