Ticket #14878: generic.diff

File generic.diff, 1.5 KB (added by Diego Andrés Sanabria Martín, 7 years ago)

Better Patch

  • django/views/generic/list.py

     
    11from django.core.paginator import Paginator, InvalidPage
    22from django.core.exceptions import ImproperlyConfigured
    33from django.http import Http404
    4 from django.utils.encoding import smart_str
    54from django.views.generic.base import TemplateResponseMixin, View
    65
    76class MultipleObjectMixin(object):
     
    7473        Get the name of the item to be used in the context.
    7574        """
    7675        if self.context_object_name:
    77             return self.context_object_name
    78         elif hasattr(object_list, 'model'):
    79             return smart_str(object_list.model._meta.verbose_name_plural)
     76            return self.context_object_name+'_list'
    8077        else:
    81             return None
     78            return 'object_list'
    8279
    8380    def get_context_data(self, **kwargs):
    8481        """
     
    9289                'paginator': paginator,
    9390                'page_obj': page,
    9491                'is_paginated': is_paginated,
    95                 'object_list': queryset
    9692            }
    9793        else:
    9894            context = {
    9995                'paginator': None,
    10096                'page_obj': None,
    10197                'is_paginated': False,
    102                 'object_list': queryset
    10398            }
    10499        context.update(kwargs)
    105100        context_object_name = self.get_context_object_name(queryset)
Back to Top