Removed backward compatible shims to rename get_query_set and similar queryset methods.

Also removed the backward compatible shims introduced to rename the
attributes ChangeList.root_query_set and ChangeList.query_set.
This commit is contained in:
Tim Graham 2014-03-21 07:45:38 -04:00
parent 11e22129d5
commit bcc15e2b21
5 changed files with 8 additions and 59 deletions

View File

@ -36,8 +36,7 @@ from django.shortcuts import get_object_or_404
from django.template.response import SimpleTemplateResponse, TemplateResponse from django.template.response import SimpleTemplateResponse, TemplateResponse
from django.utils import six from django.utils import six
from django.utils.decorators import method_decorator from django.utils.decorators import method_decorator
from django.utils.deprecation import (RenameMethodsBase, from django.utils.deprecation import RemovedInDjango19Warning
RemovedInDjango18Warning, RemovedInDjango19Warning)
from django.utils.encoding import force_text, python_2_unicode_compatible from django.utils.encoding import force_text, python_2_unicode_compatible
from django.utils.html import escape, escapejs from django.utils.html import escape, escapejs
from django.utils.http import urlencode from django.utils.http import urlencode
@ -92,13 +91,7 @@ FORMFIELD_FOR_DBFIELD_DEFAULTS = {
csrf_protect_m = method_decorator(csrf_protect) csrf_protect_m = method_decorator(csrf_protect)
class RenameBaseModelAdminMethods(forms.MediaDefiningClass, RenameMethodsBase): class BaseModelAdmin(six.with_metaclass(forms.MediaDefiningClass)):
renamed_methods = (
('queryset', 'get_queryset', RemovedInDjango18Warning),
)
class BaseModelAdmin(six.with_metaclass(RenameBaseModelAdminMethods)):
"""Functionality common to both ModelAdmin and InlineAdmin.""" """Functionality common to both ModelAdmin and InlineAdmin."""
raw_id_fields = () raw_id_fields = ()

View File

@ -8,7 +8,7 @@ from django.core.urlresolvers import reverse
from django.db import models from django.db import models
from django.db.models.fields import FieldDoesNotExist from django.db.models.fields import FieldDoesNotExist
from django.utils import six from django.utils import six
from django.utils.deprecation import RenameMethodsBase, RemovedInDjango18Warning from django.utils.deprecation import RemovedInDjango18Warning
from django.utils.encoding import force_text from django.utils.encoding import force_text
from django.utils.translation import ugettext, ugettext_lazy from django.utils.translation import ugettext, ugettext_lazy
from django.utils.http import urlencode from django.utils.http import urlencode
@ -57,13 +57,7 @@ def _is_changelist_popup(request):
return False return False
class RenameChangeListMethods(RenameMethodsBase): class ChangeList(object):
renamed_methods = (
('get_query_set', 'get_queryset', RemovedInDjango18Warning),
)
class ChangeList(six.with_metaclass(RenameChangeListMethods)):
def __init__(self, request, model, list_display, list_display_links, def __init__(self, request, model, list_display, list_display_links,
list_filter, date_hierarchy, search_fields, list_select_related, list_filter, date_hierarchy, search_fields, list_select_related,
list_per_page, list_max_show_all, list_editable, model_admin): list_per_page, list_max_show_all, list_editable, model_admin):
@ -110,20 +104,6 @@ class ChangeList(six.with_metaclass(RenameChangeListMethods)):
self.title = title % force_text(self.opts.verbose_name) self.title = title % force_text(self.opts.verbose_name)
self.pk_attname = self.lookup_opts.pk.attname self.pk_attname = self.lookup_opts.pk.attname
@property
def root_query_set(self):
warnings.warn("`ChangeList.root_query_set` is deprecated, "
"use `root_queryset` instead.",
RemovedInDjango18Warning, 2)
return self.root_queryset
@property
def query_set(self):
warnings.warn("`ChangeList.query_set` is deprecated, "
"use `queryset` instead.",
RemovedInDjango18Warning, 2)
return self.queryset
def get_filters_params(self, params=None): def get_filters_params(self, params=None):
""" """
Returns all params except IGNORED_PARAMS Returns all params except IGNORED_PARAMS

View File

@ -12,19 +12,11 @@ from django.db.models.fields.related import ForeignObject, ForeignObjectRel
from django.db.models.related import PathInfo from django.db.models.related import PathInfo
from django.db.models.sql.datastructures import Col from django.db.models.sql.datastructures import Col
from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.models import ContentType
from django.utils import six
from django.utils.deprecation import RenameMethodsBase, RemovedInDjango18Warning
from django.utils.encoding import smart_text, python_2_unicode_compatible from django.utils.encoding import smart_text, python_2_unicode_compatible
class RenameGenericForeignKeyMethods(RenameMethodsBase):
renamed_methods = (
('get_prefetch_query_set', 'get_prefetch_queryset', RemovedInDjango18Warning),
)
@python_2_unicode_compatible @python_2_unicode_compatible
class GenericForeignKey(six.with_metaclass(RenameGenericForeignKeyMethods)): class GenericForeignKey(object):
""" """
Provides a generic relation to any object through content-type/object-id Provides a generic relation to any object through content-type/object-id
fields. fields.

View File

@ -14,7 +14,6 @@ from django.db.models.query import QuerySet
from django.db.models.sql.datastructures import Col from django.db.models.sql.datastructures import Col
from django.utils.encoding import smart_text from django.utils.encoding import smart_text
from django.utils import six from django.utils import six
from django.utils.deprecation import RenameMethodsBase, RemovedInDjango18Warning
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from django.utils.functional import curry, cached_property from django.utils.functional import curry, cached_property
from django.core import exceptions from django.core import exceptions
@ -344,14 +343,7 @@ class RelatedField(Field):
return self.rel.related_query_name or self.rel.related_name or self.opts.model_name return self.rel.related_query_name or self.rel.related_name or self.opts.model_name
class RenameRelatedObjectDescriptorMethods(RenameMethodsBase): class SingleRelatedObjectDescriptor(object):
renamed_methods = (
('get_query_set', 'get_queryset', RemovedInDjango18Warning),
('get_prefetch_query_set', 'get_prefetch_queryset', RemovedInDjango18Warning),
)
class SingleRelatedObjectDescriptor(six.with_metaclass(RenameRelatedObjectDescriptorMethods)):
# This class provides the functionality that makes the related-object # This class provides the functionality that makes the related-object
# managers available as attributes on a model class, for fields that have # managers available as attributes on a model class, for fields that have
# a single "remote" value, on the class pointed to by a related field. # a single "remote" value, on the class pointed to by a related field.
@ -479,7 +471,7 @@ class SingleRelatedObjectDescriptor(six.with_metaclass(RenameRelatedObjectDescri
setattr(value, self.related.field.get_cache_name(), instance) setattr(value, self.related.field.get_cache_name(), instance)
class ReverseSingleRelatedObjectDescriptor(six.with_metaclass(RenameRelatedObjectDescriptorMethods)): class ReverseSingleRelatedObjectDescriptor(object):
# This class provides the functionality that makes the related-object # This class provides the functionality that makes the related-object
# managers available as attributes on a model class, for fields that have # managers available as attributes on a model class, for fields that have
# a single "remote" value, on the class that defines the related field. # a single "remote" value, on the class that defines the related field.

View File

@ -6,7 +6,6 @@ from django.db.models.query import QuerySet
from django.db.models import signals from django.db.models import signals
from django.db.models.fields import FieldDoesNotExist from django.db.models.fields import FieldDoesNotExist
from django.utils import six from django.utils import six
from django.utils.deprecation import RenameMethodsBase, RemovedInDjango18Warning
from django.utils.encoding import python_2_unicode_compatible from django.utils.encoding import python_2_unicode_compatible
@ -52,15 +51,8 @@ def ensure_default_manager(sender, **kwargs):
signals.class_prepared.connect(ensure_default_manager) signals.class_prepared.connect(ensure_default_manager)
class RenameManagerMethods(RenameMethodsBase):
renamed_methods = (
('get_query_set', 'get_queryset', RemovedInDjango18Warning),
('get_prefetch_query_set', 'get_prefetch_queryset', RemovedInDjango18Warning),
)
@python_2_unicode_compatible @python_2_unicode_compatible
class BaseManager(six.with_metaclass(RenameManagerMethods)): class BaseManager(object):
# Tracks each time a Manager instance is created. Used to retain order. # Tracks each time a Manager instance is created. Used to retain order.
creation_counter = 0 creation_counter = 0