mirror of
https://github.com/django/django.git
synced 2025-11-07 07:15:35 +00:00
Fixed #14878 -- Clarified the way verbose_name_plural is used in generic list views as a context variable. Thanks to diegueus9 for the report.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@15133 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -2,6 +2,7 @@ import re
|
||||
|
||||
from django.core.exceptions import ImproperlyConfigured, ObjectDoesNotExist
|
||||
from django.http import Http404
|
||||
from django.utils.encoding import smart_str
|
||||
from django.views.generic.base import TemplateResponseMixin, View
|
||||
|
||||
|
||||
@@ -79,8 +80,8 @@ class SingleObjectMixin(object):
|
||||
if self.context_object_name:
|
||||
return self.context_object_name
|
||||
elif hasattr(obj, '_meta'):
|
||||
return re.sub('[^a-zA-Z0-9]+', '_',
|
||||
obj._meta.verbose_name.lower())
|
||||
return smart_str(re.sub('[^a-zA-Z0-9]+', '_',
|
||||
obj._meta.verbose_name.lower()))
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
import re
|
||||
|
||||
from django.core.paginator import Paginator, InvalidPage
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.http import Http404
|
||||
from django.utils.encoding import smart_str
|
||||
from django.views.generic.base import TemplateResponseMixin, View
|
||||
|
||||
|
||||
class MultipleObjectMixin(object):
|
||||
allow_empty = True
|
||||
queryset = None
|
||||
@@ -76,7 +79,8 @@ class MultipleObjectMixin(object):
|
||||
if self.context_object_name:
|
||||
return self.context_object_name
|
||||
elif hasattr(object_list, 'model'):
|
||||
return smart_str(object_list.model._meta.verbose_name_plural)
|
||||
return smart_str(re.sub('[^a-zA-Z0-9]+', '_',
|
||||
object_list.model._meta.verbose_name_plural.lower()))
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user