Ticket #15363: 0001-Fixed-15363-Renamed-get_query_set-methods-by-get_que.patch

File 0001-Fixed-15363-Renamed-get_query_set-methods-by-get_que.patch, 55.0 KB (added by charettes, 3 years ago)
  • django/contrib/admin/options.py

    From 22ea27f04e5684ca81c633bc5d2615cfb52ba46a Mon Sep 17 00:00:00 2001
    From: Simon Charette <charette.s@gmail.com>
    Date: Sun, 3 Feb 2013 05:10:35 -0500
    Subject: [PATCH] Fixed #15363 -- Renamed get_query_set methods by
     get_queryset
    
    ---
     django/contrib/admin/options.py                    |    6 +-
     django/contrib/admin/views/main.py                 |    6 +-
     django/contrib/comments/managers.py                |    4 +-
     django/contrib/comments/templatetags/comments.py   |    9 ++-
     django/contrib/contenttypes/generic.py             |    8 ++-
     django/contrib/gis/db/models/manager.py            |   65 +++++++++---------
     django/contrib/sites/managers.py                   |    7 +-
     django/db/models/fields/related.py                 |   34 ++++++----
     django/db/models/manager.py                        |   69 ++++++++++----------
     django/forms/models.py                             |    6 +-
     django/utils/deprecation.py                        |   16 +++++
     tests/modeltests/custom_managers/models.py         |   10 +--
     tests/modeltests/fixtures/models.py                |    4 +-
     tests/modeltests/generic_relations/models.py       |    4 +-
     tests/modeltests/get_object_or_404/models.py       |    4 +-
     tests/modeltests/prefetch_related/models.py        |    4 +-
     tests/modeltests/proxy_models/models.py            |    8 +--
     tests/regressiontests/admin_changelist/models.py   |    4 +-
     tests/regressiontests/admin_changelist/tests.py    |    2 +-
     tests/regressiontests/admin_filters/tests.py       |   46 ++++++-------
     tests/regressiontests/admin_views/admin.py         |    2 +-
     tests/regressiontests/admin_widgets/models.py      |    4 +-
     .../custom_managers_regress/models.py              |    4 +-
     tests/regressiontests/managers_regress/models.py   |   12 ++--
     tests/regressiontests/modeladmin/tests.py          |    2 +-
     tests/regressiontests/queries/models.py            |    8 +--
     .../reverse_single_related/models.py               |    4 +-
     27 files changed, 195 insertions(+), 157 deletions(-)
     create mode 100644 django/utils/deprecation.py
    
    diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
    index 8e0aacc..8d42313 100644
    a b class BaseModelAdmin(six.with_metaclass(forms.MediaDefiningClass)): 
    222222        Returns a QuerySet of all model instances that can be edited by the
    223223        admin site. This is used by changelist_view.
    224224        """
    225         qs = self.model._default_manager.get_query_set()
     225        qs = self.model._default_manager.get_queryset()
    226226        # TODO: this should be handled by some parameter to the ChangeList.
    227227        ordering = self.get_ordering(request)
    228228        if ordering:
    class ModelAdmin(BaseModelAdmin): 
    11871187        if (actions and request.method == 'POST' and
    11881188                'index' in request.POST and '_save' not in request.POST):
    11891189            if selected:
    1190                 response = self.response_action(request, queryset=cl.get_query_set(request))
     1190                response = self.response_action(request, queryset=cl.get_queryset(request))
    11911191                if response:
    11921192                    return response
    11931193                else:
    class ModelAdmin(BaseModelAdmin): 
    12031203                helpers.ACTION_CHECKBOX_NAME in request.POST and
    12041204                'index' not in request.POST and '_save' not in request.POST):
    12051205            if selected:
    1206                 response = self.response_action(request, queryset=cl.get_query_set(request))
     1206                response = self.response_action(request, queryset=cl.get_queryset(request))
    12071207                if response:
    12081208                    return response
    12091209                else:
  • django/contrib/admin/views/main.py

    diff --git a/django/contrib/admin/views/main.py b/django/contrib/admin/views/main.py
    index be7067f..02b45f1 100644
    a b from django.core.urlresolvers import reverse 
    77from django.db import models
    88from django.db.models.fields import FieldDoesNotExist
    99from django.utils.datastructures import SortedDict
     10from django.utils.deprecation import deprecated_get_query_set
    1011from django.utils.encoding import force_str, force_text
    1112from django.utils.translation import ugettext, ugettext_lazy
    1213from django.utils.http import urlencode
    IGNORED_PARAMS = ( 
    3334EMPTY_CHANGELIST_VALUE = ugettext_lazy('(None)')
    3435
    3536
     37@deprecated_get_query_set
    3638class ChangeList(object):
    3739    def __init__(self, request, model, list_display, list_display_links,
    3840            list_filter, date_hierarchy, search_fields, list_select_related,
    class ChangeList(object): 
    7072        else:
    7173            self.list_editable = list_editable
    7274        self.query = request.GET.get(SEARCH_VAR, '')
    73         self.query_set = self.get_query_set(request)
     75        self.query_set = self.get_queryset(request)
    7476        self.get_results(request)
    7577        if self.is_popup:
    7678            title = ugettext('Select %s')
    class ChangeList(object): 
    297299                ordering_fields[idx] = 'desc' if pfx == '-' else 'asc'
    298300        return ordering_fields
    299301
    300     def get_query_set(self, request):
     302    def get_queryset(self, request):
    301303        # First, we collect all the declared list filters.
    302304        (self.filter_specs, self.has_filters, remaining_lookup_params,
    303305         use_distinct) = self.get_filters(request)
  • django/contrib/comments/managers.py

    diff --git a/django/contrib/comments/managers.py b/django/contrib/comments/managers.py
    index bc0fc5f..6562004 100644
    a b class CommentManager(models.Manager): 
    88        """
    99        QuerySet for all comments currently in the moderation queue.
    1010        """
    11         return self.get_query_set().filter(is_public=False, is_removed=False)
     11        return self.get_queryset().filter(is_public=False, is_removed=False)
    1212
    1313    def for_model(self, model):
    1414        """
    class CommentManager(models.Manager): 
    1616        a class).
    1717        """
    1818        ct = ContentType.objects.get_for_model(model)
    19         qs = self.get_query_set().filter(content_type=ct)
     19        qs = self.get_queryset().filter(content_type=ct)
    2020        if isinstance(model, models.Model):
    2121            qs = qs.filter(object_pk=force_text(model._get_pk_val()))
    2222        return qs
  • django/contrib/comments/templatetags/comments.py

    diff --git a/django/contrib/comments/templatetags/comments.py b/django/contrib/comments/templatetags/comments.py
    index 4d4eb23..e82fbed 100644
    a b from django.template.loader import render_to_string 
    33from django.conf import settings
    44from django.contrib.contenttypes.models import ContentType
    55from django.contrib import comments
     6from django.utils.deprecation import deprecated_get_query_set
    67from django.utils.encoding import smart_text
    78
    89register = template.Library()
    910
     11
     12@deprecated_get_query_set
    1013class BaseCommentNode(template.Node):
    1114    """
    1215    Base helper class (abstract) for handling the get_comment_* template tags.
    class BaseCommentNode(template.Node): 
    6467        self.comment = comment
    6568
    6669    def render(self, context):
    67         qs = self.get_query_set(context)
     70        qs = self.get_queryset(context)
    6871        context[self.as_varname] = self.get_context_value_from_queryset(context, qs)
    6972        return ''
    7073
    71     def get_query_set(self, context):
     74    def get_queryset(self, context):
    7275        ctype, object_pk = self.get_target_ctype_pk(context)
    7376        if not object_pk:
    7477            return self.comment_model.objects.none()
    class RenderCommentListNode(CommentListNode): 
    205208                "comments/%s/list.html" % ctype.app_label,
    206209                "comments/list.html"
    207210            ]
    208             qs = self.get_query_set(context)
     211            qs = self.get_queryset(context)
    209212            context.push()
    210213            liststr = render_to_string(template_search_list, {
    211214                "comment_list" : self.get_context_value_from_queryset(context, qs)
  • django/contrib/contenttypes/generic.py

    diff --git a/django/contrib/contenttypes/generic.py b/django/contrib/contenttypes/generic.py
    index cda4d46..ca9f018 100644
    a b from django.forms import ModelForm 
    1616from django.forms.models import BaseModelFormSet, modelformset_factory, save_instance
    1717from django.contrib.admin.options import InlineModelAdmin, flatten_fieldsets
    1818from django.contrib.contenttypes.models import ContentType
     19from django.utils.deprecation import deprecated_get_query_set
    1920from django.utils.encoding import smart_text
    2021
    2122
    def create_generic_related_manager(superclass): 
    294295    Manager) and adds behavior for generic related objects.
    295296    """
    296297
     298    @deprecated_get_query_set
    297299    class GenericRelatedObjectManager(superclass):
    298300        def __init__(self, model=None, instance=None, symmetrical=None,
    299301                     source_col_name=None, target_col_name=None, content_type=None,
    def create_generic_related_manager(superclass): 
    316318                '%s__exact' % object_id_field_name: instance._get_pk_val(),
    317319            }
    318320
    319         def get_query_set(self):
     321        def get_queryset(self):
    320322            try:
    321323                return self.instance._prefetched_objects_cache[self.prefetch_cache_name]
    322324            except (AttributeError, KeyError):
    323325                db = self._db or router.db_for_read(self.model, instance=self.instance)
    324                 return super(GenericRelatedObjectManager, self).get_query_set().using(db).filter(**self.core_filters)
     326                return super(GenericRelatedObjectManager, self).get_queryset().using(db).filter(**self.core_filters)
    325327
    326328        def get_prefetch_query_set(self, instances):
    327329            db = self._db or router.db_for_read(self.model, instance=instances[0])
    def create_generic_related_manager(superclass): 
    330332                '%s__in' % self.object_id_field_name:
    331333                    set(obj._get_pk_val() for obj in instances)
    332334                }
    333             qs = super(GenericRelatedObjectManager, self).get_query_set().using(db).filter(**query)
     335            qs = super(GenericRelatedObjectManager, self).get_queryset().using(db).filter(**query)
    334336            # We (possibly) need to convert object IDs to the type of the
    335337            # instances' PK in order to match up instances:
    336338            object_id_converter = instances[0]._meta.pk.to_python
  • django/contrib/gis/db/models/manager.py

    diff --git a/django/contrib/gis/db/models/manager.py b/django/contrib/gis/db/models/manager.py
    index 61fb821..9cd101e 100644
    a b  
    11from django.db.models.manager import Manager
    22from django.contrib.gis.db.models.query import GeoQuerySet
     3from django.utils.deprecation import deprecated_get_query_set
    34
     5
     6@deprecated_get_query_set
    47class GeoManager(Manager):
    58    "Overrides Manager to return Geographic QuerySets."
    69
    class GeoManager(Manager): 
    912    # properly.
    1013    use_for_related_fields = True
    1114
    12     def get_query_set(self):
     15    def get_queryset(self):
    1316        return GeoQuerySet(self.model, using=self._db)
    1417
    1518    def area(self, *args, **kwargs):
    16         return self.get_query_set().area(*args, **kwargs)
     19        return self.get_queryset().area(*args, **kwargs)
    1720
    1821    def centroid(self, *args, **kwargs):
    19         return self.get_query_set().centroid(*args, **kwargs)
     22        return self.get_queryset().centroid(*args, **kwargs)
    2023
    2124    def collect(self, *args, **kwargs):
    22         return self.get_query_set().collect(*args, **kwargs)
     25        return self.get_queryset().collect(*args, **kwargs)
    2326
    2427    def difference(self, *args, **kwargs):
    25         return self.get_query_set().difference(*args, **kwargs)
     28        return self.get_queryset().difference(*args, **kwargs)
    2629
    2730    def distance(self, *args, **kwargs):
    28         return self.get_query_set().distance(*args, **kwargs)
     31        return self.get_queryset().distance(*args, **kwargs)
    2932
    3033    def envelope(self, *args, **kwargs):
    31         return self.get_query_set().envelope(*args, **kwargs)
     34        return self.get_queryset().envelope(*args, **kwargs)
    3235
    3336    def extent(self, *args, **kwargs):
    34         return self.get_query_set().extent(*args, **kwargs)
     37        return self.get_queryset().extent(*args, **kwargs)
    3538
    3639    def extent3d(self, *args, **kwargs):
    37         return self.get_query_set().extent3d(*args, **kwargs)
     40        return self.get_queryset().extent3d(*args, **kwargs)
    3841
    3942    def force_rhr(self, *args, **kwargs):
    40         return self.get_query_set().force_rhr(*args, **kwargs)
     43        return self.get_queryset().force_rhr(*args, **kwargs)
    4144
    4245    def geohash(self, *args, **kwargs):
    43         return self.get_query_set().geohash(*args, **kwargs)
     46        return self.get_queryset().geohash(*args, **kwargs)
    4447
    4548    def geojson(self, *args, **kwargs):
    46         return self.get_query_set().geojson(*args, **kwargs)
     49        return self.get_queryset().geojson(*args, **kwargs)
    4750
    4851    def gml(self, *args, **kwargs):
    49         return self.get_query_set().gml(*args, **kwargs)
     52        return self.get_queryset().gml(*args, **kwargs)
    5053
    5154    def intersection(self, *args, **kwargs):
    52         return self.get_query_set().intersection(*args, **kwargs)
     55        return self.get_queryset().intersection(*args, **kwargs)
    5356
    5457    def kml(self, *args, **kwargs):
    55         return self.get_query_set().kml(*args, **kwargs)
     58        return self.get_queryset().kml(*args, **kwargs)
    5659
    5760    def length(self, *args, **kwargs):
    58         return self.get_query_set().length(*args, **kwargs)
     61        return self.get_queryset().length(*args, **kwargs)
    5962
    6063    def make_line(self, *args, **kwargs):
    61         return self.get_query_set().make_line(*args, **kwargs)
     64        return self.get_queryset().make_line(*args, **kwargs)
    6265
    6366    def mem_size(self, *args, **kwargs):
    64         return self.get_query_set().mem_size(*args, **kwargs)
     67        return self.get_queryset().mem_size(*args, **kwargs)
    6568
    6669    def num_geom(self, *args, **kwargs):
    67         return self.get_query_set().num_geom(*args, **kwargs)
     70        return self.get_queryset().num_geom(*args, **kwargs)
    6871
    6972    def num_points(self, *args, **kwargs):
    70         return self.get_query_set().num_points(*args, **kwargs)
     73        return self.get_queryset().num_points(*args, **kwargs)
    7174
    7275    def perimeter(self, *args, **kwargs):
    73         return self.get_query_set().perimeter(*args, **kwargs)
     76        return self.get_queryset().perimeter(*args, **kwargs)
    7477
    7578    def point_on_surface(self, *args, **kwargs):
    76         return self.get_query_set().point_on_surface(*args, **kwargs)
     79        return self.get_queryset().point_on_surface(*args, **kwargs)
    7780
    7881    def reverse_geom(self, *args, **kwargs):
    79         return self.get_query_set().reverse_geom(*args, **kwargs)
     82        return self.get_queryset().reverse_geom(*args, **kwargs)
    8083
    8184    def scale(self, *args, **kwargs):
    82         return self.get_query_set().scale(*args, **kwargs)
     85        return self.get_queryset().scale(*args, **kwargs)
    8386
    8487    def snap_to_grid(self, *args, **kwargs):
    85         return self.get_query_set().snap_to_grid(*args, **kwargs)
     88        return self.get_queryset().snap_to_grid(*args, **kwargs)
    8689
    8790    def svg(self, *args, **kwargs):
    88         return self.get_query_set().svg(*args, **kwargs)
     91        return self.get_queryset().svg(*args, **kwargs)
    8992
    9093    def sym_difference(self, *args, **kwargs):
    91         return self.get_query_set().sym_difference(*args, **kwargs)
     94        return self.get_queryset().sym_difference(*args, **kwargs)
    9295
    9396    def transform(self, *args, **kwargs):
    94         return self.get_query_set().transform(*args, **kwargs)
     97        return self.get_queryset().transform(*args, **kwargs)
    9598
    9699    def translate(self, *args, **kwargs):
    97         return self.get_query_set().translate(*args, **kwargs)
     100        return self.get_queryset().translate(*args, **kwargs)
    98101
    99102    def union(self, *args, **kwargs):
    100         return self.get_query_set().union(*args, **kwargs)
     103        return self.get_queryset().union(*args, **kwargs)
    101104
    102105    def unionagg(self, *args, **kwargs):
    103         return self.get_query_set().unionagg(*args, **kwargs)
     106        return self.get_queryset().unionagg(*args, **kwargs)
  • django/contrib/sites/managers.py

    diff --git a/django/contrib/sites/managers.py b/django/contrib/sites/managers.py
    index 3df485a..3889e11 100644
    a b  
    11from django.conf import settings
    22from django.db import models
    33from django.db.models.fields import FieldDoesNotExist
     4from django.utils.deprecation import deprecated_get_query_set
    45
     6
     7@deprecated_get_query_set
    58class CurrentSiteManager(models.Manager):
    69    "Use this to limit objects to those associated with the current site."
    710    def __init__(self, field_name=None):
    class CurrentSiteManager(models.Manager): 
    3538                    (self.__class__.__name__, self.__field_name, self.model._meta.object_name))
    3639        self.__is_validated = True
    3740   
    38     def get_query_set(self):
     41    def get_queryset(self):
    3942        if not self.__is_validated:
    4043            self._validate_field_name()
    41         return super(CurrentSiteManager, self).get_query_set().filter(**{self.__field_name + '__id__exact': settings.SITE_ID})
     44        return super(CurrentSiteManager, self).get_queryset().filter(**{self.__field_name + '__id__exact': settings.SITE_ID})
  • django/db/models/fields/related.py

    diff --git a/django/db/models/fields/related.py b/django/db/models/fields/related.py
    index ae792a3..a7e1d11 100644
    a b  
    11from operator import attrgetter
    22
     3from django import forms
     4from django.core import exceptions
    35from django.db import connection, router
    46from django.db.backends import util
    57from django.db.models import signals, get_model
    from django.db.models.query_utils import QueryWrapper 
    1113from django.db.models.deletion import CASCADE
    1214from django.utils.encoding import smart_text
    1315from django.utils import six
     16from django.utils.deprecation import deprecated_get_query_set
    1417from django.utils.translation import ugettext_lazy as _, string_concat
    1518from django.utils.functional import curry, cached_property
    16 from django.core import exceptions
    17 from django import forms
     19
    1820
    1921RECURSIVE_RELATIONSHIP_CONSTANT = 'self'
    2022
    class RelatedField(object): 
    225227        return self.rel.related_name or self.opts.object_name.lower()
    226228
    227229
     230@deprecated_get_query_set
    228231class SingleRelatedObjectDescriptor(object):
    229232    # This class provides the functionality that makes the related-object
    230233    # managers available as attributes on a model class, for fields that have
    class SingleRelatedObjectDescriptor(object): 
    238241    def is_cached(self, instance):
    239242        return hasattr(instance, self.cache_name)
    240243
    241     def get_query_set(self, **db_hints):
     244    def get_queryset(self, **db_hints):
    242245        db = router.db_for_read(self.related.model, **db_hints)
    243246        return self.related.model._base_manager.using(db)
    244247
    class SingleRelatedObjectDescriptor(object): 
    247250        instance_attr = lambda obj: obj._get_pk_val()
    248251        instances_dict = dict((instance_attr(inst), inst) for inst in instances)
    249252        params = {'%s__pk__in' % self.related.field.name: list(instances_dict)}
    250         qs = self.get_query_set(instance=instances[0]).filter(**params)
     253        qs = self.get_queryset(instance=instances[0]).filter(**params)
    251254        # Since we're going to assign directly in the cache,
    252255        # we must manage the reverse relation cache manually.
    253256        rel_obj_cache_name = self.related.field.get_cache_name()
    class SingleRelatedObjectDescriptor(object): 
    268271            else:
    269272                params = {'%s__pk' % self.related.field.name: related_pk}
    270273                try:
    271                     rel_obj = self.get_query_set(instance=instance).get(**params)
     274                    rel_obj = self.get_queryset(instance=instance).get(**params)
    272275                except self.related.model.DoesNotExist:
    273276                    rel_obj = None
    274277                else:
    class SingleRelatedObjectDescriptor(object): 
    321324        setattr(value, self.related.field.get_cache_name(), instance)
    322325
    323326
     327@deprecated_get_query_set
    324328class ReverseSingleRelatedObjectDescriptor(object):
    325329    # This class provides the functionality that makes the related-object
    326330    # managers available as attributes on a model class, for fields that have
    class ReverseSingleRelatedObjectDescriptor(object): 
    334338    def is_cached(self, instance):
    335339        return hasattr(instance, self.cache_name)
    336340
    337     def get_query_set(self, **db_hints):
     341    def get_queryset(self, **db_hints):
    338342        db = router.db_for_read(self.field.rel.to, **db_hints)
    339343        rel_mgr = self.field.rel.to._default_manager
    340344        # If the related manager indicates that it should be used for
    class ReverseSingleRelatedObjectDescriptor(object): 
    353357            params = {'%s__pk__in' % self.field.rel.field_name: list(instances_dict)}
    354358        else:
    355359            params = {'%s__in' % self.field.rel.field_name: list(instances_dict)}
    356         qs = self.get_query_set(instance=instances[0]).filter(**params)
     360        qs = self.get_queryset(instance=instances[0]).filter(**params)
    357361        # Since we're going to assign directly in the cache,
    358362        # we must manage the reverse relation cache manually.
    359363        if not self.field.rel.multiple:
    class ReverseSingleRelatedObjectDescriptor(object): 
    378382                    params = {'%s__%s' % (self.field.rel.field_name, other_field.rel.field_name): val}
    379383                else:
    380384                    params = {'%s__exact' % self.field.rel.field_name: val}
    381                 qs = self.get_query_set(instance=instance)
     385                qs = self.get_queryset(instance=instance)
    382386                # Assuming the database enforces foreign keys, this won't fail.
    383387                rel_obj = qs.get(**params)
    384388                if not self.field.rel.multiple:
    class ForeignRelatedObjectsDescriptor(object): 
    481485        rel_model = self.related.model
    482486        attname = rel_field.rel.get_related_field().attname
    483487
     488        @deprecated_get_query_set
    484489        class RelatedManager(superclass):
    485490            def __init__(self, instance):
    486491                super(RelatedManager, self).__init__()
    class ForeignRelatedObjectsDescriptor(object): 
    490495                }
    491496                self.model = rel_model
    492497
    493             def get_query_set(self):
     498            def get_queryset(self):
    494499                try:
    495500                    return self.instance._prefetched_objects_cache[rel_field.related_query_name()]
    496501                except (AttributeError, KeyError):
    497502                    db = self._db or router.db_for_read(self.model, instance=self.instance)
    498                     qs = super(RelatedManager, self).get_query_set().using(db).filter(**self.core_filters)
     503                    qs = super(RelatedManager, self).get_queryset().using(db).filter(**self.core_filters)
    499504                    if getattr(self.instance, attname) is None:
    500505                        return qs.none()
    501506                    qs._known_related_objects = {rel_field: {self.instance.pk: self.instance}}
    class ForeignRelatedObjectsDescriptor(object): 
    507512                instances_dict = dict((instance_attr(inst), inst) for inst in instances)
    508513                db = self._db or router.db_for_read(self.model, instance=instances[0])
    509514                query = {'%s__%s__in' % (rel_field.name, attname): list(instances_dict)}
    510                 qs = super(RelatedManager, self).get_query_set().using(db).filter(**query)
     515                qs = super(RelatedManager, self).get_queryset().using(db).filter(**query)
    511516                # Since we just bypassed this class' get_query_set(), we must manage
    512517                # the reverse relation manually.
    513518                for rel_obj in qs:
    class ForeignRelatedObjectsDescriptor(object): 
    561566def create_many_related_manager(superclass, rel):
    562567    """Creates a manager that subclasses 'superclass' (which is a Manager)
    563568    and adds behavior for many-to-many related objects."""
     569    @deprecated_get_query_set
    564570    class ManyRelatedManager(superclass):
    565571        def __init__(self, model=None, query_field_name=None, instance=None, symmetrical=None,
    566572                     source_field_name=None, target_field_name=None, reverse=False,
    def create_many_related_manager(superclass, rel): 
    602608            else:
    603609                return obj.pk
    604610
    605         def get_query_set(self):
     611        def get_queryset(self):
    606612            try:
    607613                return self.instance._prefetched_objects_cache[self.prefetch_cache_name]
    608614            except (AttributeError, KeyError):
    609615                db = self._db or router.db_for_read(self.instance.__class__, instance=self.instance)
    610                 return super(ManyRelatedManager, self).get_query_set().using(db)._next_is_sticky().filter(**self.core_filters)
     616                return super(ManyRelatedManager, self).get_queryset().using(db)._next_is_sticky().filter(**self.core_filters)
    611617
    612618        def get_prefetch_query_set(self, instances):
    613619            instance = instances[0]
    def create_many_related_manager(superclass, rel): 
    615621            db = self._db or router.db_for_read(instance.__class__, instance=instance)
    616622            query = {'%s__pk__in' % self.query_field_name:
    617623                         set(obj._get_pk_val() for obj in instances)}
    618             qs = super(ManyRelatedManager, self).get_query_set().using(db)._next_is_sticky().filter(**query)
     624            qs = super(ManyRelatedManager, self).get_queryset().using(db)._next_is_sticky().filter(**query)
    619625
    620626            # M2M: need to annotate the query in order to get the primary model
    621627            # that the secondary model was actually related to. We know that
  • django/db/models/manager.py

    diff --git a/django/db/models/manager.py b/django/db/models/manager.py
    index 816f619..91765c3 100644
    a b from django.db import router 
    33from django.db.models.query import QuerySet, insert_query, RawQuerySet
    44from django.db.models import signals
    55from django.db.models.fields import FieldDoesNotExist
     6from django.utils.deprecation import deprecated_get_query_set
    67
    78
    89def ensure_default_manager(sender, **kwargs):
    def ensure_default_manager(sender, **kwargs): 
    4748signals.class_prepared.connect(ensure_default_manager)
    4849
    4950
     51@deprecated_get_query_set
    5052class Manager(object):
    5153    # Tracks each time a Manager instance is created. Used to retain order.
    5254    creation_counter = 0
    class Manager(object): 
    115117    def get_empty_query_set(self):
    116118        return QuerySet(self.model, using=self._db).none()
    117119
    118     def get_query_set(self):
     120    def get_queryset(self):
    119121        """Returns a new QuerySet object.  Subclasses can override this method
    120122        to easily customize the behavior of the Manager.
    121123        """
    class Manager(object): 
    125127        return self.get_empty_query_set()
    126128
    127129    def all(self):
    128         return self.get_query_set()
     130        return self.get_queryset()
    129131
    130132    def count(self):
    131         return self.get_query_set().count()
     133        return self.get_queryset().count()
    132134
    133135    def dates(self, *args, **kwargs):
    134         return self.get_query_set().dates(*args, **kwargs)
     136        return self.get_queryset().dates(*args, **kwargs)
    135137
    136138    def distinct(self, *args, **kwargs):
    137         return self.get_query_set().distinct(*args, **kwargs)
     139        return self.get_queryset().distinct(*args, **kwargs)
    138140
    139141    def extra(self, *args, **kwargs):
    140         return self.get_query_set().extra(*args, **kwargs)
     142        return self.get_queryset().extra(*args, **kwargs)
    141143
    142144    def get(self, *args, **kwargs):
    143         return self.get_query_set().get(*args, **kwargs)
     145        return self.get_queryset().get(*args, **kwargs)
    144146
    145147    def get_or_create(self, **kwargs):
    146         return self.get_query_set().get_or_create(**kwargs)
     148        return self.get_queryset().get_or_create(**kwargs)
    147149
    148150    def create(self, **kwargs):
    149         return self.get_query_set().create(**kwargs)
     151        return self.get_queryset().create(**kwargs)
    150152
    151153    def bulk_create(self, *args, **kwargs):
    152         return self.get_query_set().bulk_create(*args, **kwargs)
     154        return self.get_queryset().bulk_create(*args, **kwargs)
    153155
    154156    def filter(self, *args, **kwargs):
    155         return self.get_query_set().filter(*args, **kwargs)
     157        return self.get_queryset().filter(*args, **kwargs)
    156158
    157159    def aggregate(self, *args, **kwargs):
    158         return self.get_query_set().aggregate(*args, **kwargs)
     160        return self.get_queryset().aggregate(*args, **kwargs)
    159161
    160162    def annotate(self, *args, **kwargs):
    161         return self.get_query_set().annotate(*args, **kwargs)
     163        return self.get_queryset().annotate(*args, **kwargs)
    162164
    163165    def complex_filter(self, *args, **kwargs):
    164         return self.get_query_set().complex_filter(*args, **kwargs)
     166        return self.get_queryset().complex_filter(*args, **kwargs)
    165167
    166168    def exclude(self, *args, **kwargs):
    167         return self.get_query_set().exclude(*args, **kwargs)
     169        return self.get_queryset().exclude(*args, **kwargs)
    168170
    169171    def in_bulk(self, *args, **kwargs):
    170         return self.get_query_set().in_bulk(*args, **kwargs)
     172        return self.get_queryset().in_bulk(*args, **kwargs)
    171173
    172174    def iterator(self, *args, **kwargs):
    173         return self.get_query_set().iterator(*args, **kwargs)
     175        return self.get_queryset().iterator(*args, **kwargs)
    174176
    175177    def earliest(self, *args, **kwargs):
    176         return self.get_query_set().earliest(*args, **kwargs)
     178        return self.get_queryset().earliest(*args, **kwargs)
    177179
    178180    def latest(self, *args, **kwargs):
    179         return self.get_query_set().latest(*args, **kwargs)
     181        return self.get_queryset().latest(*args, **kwargs)
    180182
    181183    def order_by(self, *args, **kwargs):
    182         return self.get_query_set().order_by(*args, **kwargs)
     184        return self.get_queryset().order_by(*args, **kwargs)
    183185
    184186    def select_for_update(self, *args, **kwargs):
    185         return self.get_query_set().select_for_update(*args, **kwargs)
     187        return self.get_queryset().select_for_update(*args, **kwargs)
    186188
    187189    def select_related(self, *args, **kwargs):
    188         return self.get_query_set().select_related(*args, **kwargs)
     190        return self.get_queryset().select_related(*args, **kwargs)
    189191
    190192    def prefetch_related(self, *args, **kwargs):
    191         return self.get_query_set().prefetch_related(*args, **kwargs)
     193        return self.get_queryset().prefetch_related(*args, **kwargs)
    192194
    193195    def values(self, *args, **kwargs):
    194         return self.get_query_set().values(*args, **kwargs)
     196        return self.get_queryset().values(*args, **kwargs)
    195197
    196198    def values_list(self, *args, **kwargs):
    197         return self.get_query_set().values_list(*args, **kwargs)
     199        return self.get_queryset().values_list(*args, **kwargs)
    198200
    199201    def update(self, *args, **kwargs):
    200         return self.get_query_set().update(*args, **kwargs)
     202        return self.get_queryset().update(*args, **kwargs)
    201203
    202204    def reverse(self, *args, **kwargs):
    203         return self.get_query_set().reverse(*args, **kwargs)
     205        return self.get_queryset().reverse(*args, **kwargs)
    204206
    205207    def defer(self, *args, **kwargs):
    206         return self.get_query_set().defer(*args, **kwargs)
     208        return self.get_queryset().defer(*args, **kwargs)
    207209
    208210    def only(self, *args, **kwargs):
    209         return self.get_query_set().only(*args, **kwargs)
     211        return self.get_queryset().only(*args, **kwargs)
    210212
    211213    def using(self, *args, **kwargs):
    212         return self.get_query_set().using(*args, **kwargs)
     214        return self.get_queryset().using(*args, **kwargs)
    213215
    214216    def exists(self, *args, **kwargs):
    215         return self.get_query_set().exists(*args, **kwargs)
     217        return self.get_queryset().exists(*args, **kwargs)
    216218
    217219    def _insert(self, objs, fields, **kwargs):
    218220        return insert_query(self.model, objs, fields, **kwargs)
    219221
    220222    def _update(self, values, **kwargs):
    221         return self.get_query_set()._update(values, **kwargs)
     223        return self.get_queryset()._update(values, **kwargs)
    222224
    223225    def raw(self, raw_query, params=None, *args, **kwargs):
    224226        return RawQuerySet(raw_query=raw_query, model=self.model, params=params, using=self._db, *args, **kwargs)
    class SwappedManagerDescriptor(object): 
    260262        ))
    261263
    262264
     265@deprecated_get_query_set
    263266class EmptyManager(Manager):
    264267    def __init__(self, model):
    265268        super(EmptyManager, self).__init__()
    266269        self.model = model
    267270
    268     def get_query_set(self):
     271    def get_queryset(self):
    269272        return self.get_empty_query_set()
  • django/forms/models.py

    diff --git a/django/forms/models.py b/django/forms/models.py
    index 837da74..fa27bb0 100644
    a b class BaseModelFormSet(BaseFormSet): 
    479479            if self.queryset is not None:
    480480                qs = self.queryset
    481481            else:
    482                 qs = self.model._default_manager.get_query_set()
     482                qs = self.model._default_manager.get_queryset()
    483483
    484484            # If the queryset isn't already ordered we need to add an
    485485            # artificial ordering here to make sure that all formsets
    class BaseModelFormSet(BaseFormSet): 
    674674                except IndexError:
    675675                    pk_value = None
    676676            if isinstance(pk, OneToOneField) or isinstance(pk, ForeignKey):
    677                 qs = pk.rel.to._default_manager.get_query_set()
     677                qs = pk.rel.to._default_manager.get_queryset()
    678678            else:
    679                 qs = self.model._default_manager.get_query_set()
     679                qs = self.model._default_manager.get_queryset()
    680680            qs = qs.using(form.instance._state.db)
    681681            form.fields[self._pk_field.name] = ModelChoiceField(qs, initial=pk_value, required=False, widget=HiddenInput)
    682682        super(BaseModelFormSet, self).add_fields(form, index)
  • new file django/utils/deprecation.py

    diff --git a/django/utils/deprecation.py b/django/utils/deprecation.py
    new file mode 100644
    index 0000000..6f93325
    - +  
     1from __future__ import unicode_literals
     2import warnings
     3
     4
     5def deprecated_get_query_set(cls):
     6    """
     7    A class decorator that raises a warning when `get_query_set` is called
     8    instead of `get_queryset`.
     9    """
     10    def get_query_set(self, *args, **kwargs):
     11        warnings.warn(
     12            ('`%s.get_query_set` is deprecated, use `get_queryset` instead.' % cls.__name__),
     13            PendingDeprecationWarning, 2)
     14        return cls.get_queryset(self, *args, **kwargs)
     15    cls.get_query_set = get_query_set
     16    return cls
     17 No newline at end of file
  • tests/modeltests/custom_managers/models.py

    diff --git a/tests/modeltests/custom_managers/models.py b/tests/modeltests/custom_managers/models.py
    index de7c177..2f5e62f 100644
    a b class Person(models.Model): 
    3030    def __str__(self):
    3131        return "%s %s" % (self.first_name, self.last_name)
    3232
    33 # An example of a custom manager that sets get_query_set().
     33# An example of a custom manager that sets get_queryset().
    3434
    3535class PublishedBookManager(models.Manager):
    36     def get_query_set(self):
    37         return super(PublishedBookManager, self).get_query_set().filter(is_published=True)
     36    def get_queryset(self):
     37        return super(PublishedBookManager, self).get_queryset().filter(is_published=True)
    3838
    3939@python_2_unicode_compatible
    4040class Book(models.Model):
    class Book(models.Model): 
    5050# An example of providing multiple custom managers.
    5151
    5252class FastCarManager(models.Manager):
    53     def get_query_set(self):
    54         return super(FastCarManager, self).get_query_set().filter(top_speed__gt=150)
     53    def get_queryset(self):
     54        return super(FastCarManager, self).get_queryset().filter(top_speed__gt=150)
    5555
    5656@python_2_unicode_compatible
    5757class Car(models.Model):
  • tests/modeltests/fixtures/models.py

    diff --git a/tests/modeltests/fixtures/models.py b/tests/modeltests/fixtures/models.py
    index 8bd3501..976716f 100644
    a b class Person(models.Model): 
    7878        return (self.name,)
    7979
    8080class SpyManager(PersonManager):
    81     def get_query_set(self):
    82         return super(SpyManager, self).get_query_set().filter(cover_blown=False)
     81    def get_queryset(self):
     82        return super(SpyManager, self).get_queryset().filter(cover_blown=False)
    8383
    8484class Spy(Person):
    8585    objects = SpyManager()
  • tests/modeltests/generic_relations/models.py

    diff --git a/tests/modeltests/generic_relations/models.py b/tests/modeltests/generic_relations/models.py
    index 18d7623..34dc8d3 100644
    a b class Mineral(models.Model): 
    8888        return self.name
    8989
    9090class GeckoManager(models.Manager):
    91     def get_query_set(self):
    92         return super(GeckoManager, self).get_query_set().filter(has_tail=True)
     91    def get_queryset(self):
     92        return super(GeckoManager, self).get_queryset().filter(has_tail=True)
    9393
    9494class Gecko(models.Model):
    9595    has_tail = models.BooleanField()
  • tests/modeltests/get_object_or_404/models.py

    diff --git a/tests/modeltests/get_object_or_404/models.py b/tests/modeltests/get_object_or_404/models.py
    index bda0605..bb9aa60 100644
    a b class Author(models.Model): 
    2222        return self.name
    2323
    2424class ArticleManager(models.Manager):
    25     def get_query_set(self):
    26         return super(ArticleManager, self).get_query_set().filter(authors__name__icontains='sir')
     25    def get_queryset(self):
     26        return super(ArticleManager, self).get_queryset().filter(authors__name__icontains='sir')
    2727
    2828@python_2_unicode_compatible
    2929class Article(models.Model):
  • tests/modeltests/prefetch_related/models.py

    diff --git a/tests/modeltests/prefetch_related/models.py b/tests/modeltests/prefetch_related/models.py
    index e58997d..81c5698 100644
    a b class Qualification(models.Model): 
    8787
    8888
    8989class TeacherManager(models.Manager):
    90     def get_query_set(self):
    91         return super(TeacherManager, self).get_query_set().prefetch_related('qualifications')
     90    def get_queryset(self):
     91        return super(TeacherManager, self).get_queryset().prefetch_related('qualifications')
    9292
    9393
    9494@python_2_unicode_compatible
  • tests/modeltests/proxy_models/models.py

    diff --git a/tests/modeltests/proxy_models/models.py b/tests/modeltests/proxy_models/models.py
    index 6c962aa..ffb3665 100644
    a b from django.utils.encoding import python_2_unicode_compatible 
    1010# A couple of managers for testing managing overriding in proxy model cases.
    1111
    1212class PersonManager(models.Manager):
    13     def get_query_set(self):
    14         return super(PersonManager, self).get_query_set().exclude(name="fred")
     13    def get_queryset(self):
     14        return super(PersonManager, self).get_queryset().exclude(name="fred")
    1515
    1616class SubManager(models.Manager):
    17     def get_query_set(self):
    18         return super(SubManager, self).get_query_set().exclude(name="wilma")
     17    def get_queryset(self):
     18        return super(SubManager, self).get_queryset().exclude(name="wilma")
    1919
    2020@python_2_unicode_compatible
    2121class Person(models.Model):
  • tests/regressiontests/admin_changelist/models.py

    diff --git a/tests/regressiontests/admin_changelist/models.py b/tests/regressiontests/admin_changelist/models.py
    index 4ba2f9c..786b438 100644
    a b class UnorderedObject(models.Model): 
    7474
    7575
    7676class OrderedObjectManager(models.Manager):
    77     def get_query_set(self):
    78         return super(OrderedObjectManager, self).get_query_set().order_by('number')
     77    def get_queryset(self):
     78        return super(OrderedObjectManager, self).get_queryset().order_by('number')
    7979
    8080class OrderedObject(models.Model):
    8181    """
  • tests/regressiontests/admin_changelist/tests.py

    diff --git a/tests/regressiontests/admin_changelist/tests.py b/tests/regressiontests/admin_changelist/tests.py
    index 7a3a5c0..2f94cc7 100644
    a b class ChangeListTests(TestCase): 
    3939
    4040    def test_select_related_preserved(self):
    4141        """
    42         Regression test for #10348: ChangeList.get_query_set() shouldn't
     42        Regression test for #10348: ChangeList.get_queryset() shouldn't
    4343        overwrite a custom select_related provided by ModelAdmin.queryset().
    4444        """
    4545        m = ChildAdmin(Child, admin.site)
  • tests/regressiontests/admin_filters/tests.py

    diff --git a/tests/regressiontests/admin_filters/tests.py b/tests/regressiontests/admin_filters/tests.py
    index 11f792e..d25c8f4 100644
    a b class ListFiltersTests(TestCase): 
    183183        changelist = self.get_changelist(request, Book, modeladmin)
    184184
    185185        # Make sure the correct queryset is returned
    186         queryset = changelist.get_query_set(request)
     186        queryset = changelist.get_queryset(request)
    187187        self.assertEqual(list(queryset), [self.django_book, self.djangonaut_book])
    188188
    189189        # Make sure the correct choice is selected
    class ListFiltersTests(TestCase): 
    200200        changelist = self.get_changelist(request, Book, modeladmin)
    201201
    202202        # Make sure the correct queryset is returned
    203         queryset = changelist.get_query_set(request)
     203        queryset = changelist.get_queryset(request)
    204204        if (self.today.year, self.today.month) == (self.one_week_ago.year, self.one_week_ago.month):
    205205            # In case one week ago is in the same month.
    206206            self.assertEqual(list(queryset), [self.gipsy_book, self.django_book, self.djangonaut_book])
    class ListFiltersTests(TestCase): 
    221221        changelist = self.get_changelist(request, Book, modeladmin)
    222222
    223223        # Make sure the correct queryset is returned
    224         queryset = changelist.get_query_set(request)
     224        queryset = changelist.get_queryset(request)
    225225        if self.today.year == self.one_week_ago.year:
    226226            # In case one week ago is in the same year.
    227227            self.assertEqual(list(queryset), [self.gipsy_book, self.django_book, self.djangonaut_book])
    class ListFiltersTests(TestCase): 
    242242        changelist = self.get_changelist(request, Book, modeladmin)
    243243
    244244        # Make sure the correct queryset is returned
    245         queryset = changelist.get_query_set(request)
     245        queryset = changelist.get_queryset(request)
    246246        self.assertEqual(list(queryset), [self.gipsy_book, self.django_book, self.djangonaut_book])
    247247
    248248        # Make sure the correct choice is selected
    class ListFiltersTests(TestCase): 
    266266        changelist = self.get_changelist(request, Book, modeladmin)
    267267
    268268        # Make sure the correct queryset is returned
    269         queryset = changelist.get_query_set(request)
     269        queryset = changelist.get_queryset(request)
    270270        self.assertEqual(list(queryset), [self.django_book])
    271271
    272272        # Make sure the last choice is None and is selected
    class ListFiltersTests(TestCase): 
    293293        changelist = self.get_changelist(request, Book, modeladmin)
    294294
    295295        # Make sure the correct queryset is returned
    296         queryset = changelist.get_query_set(request)
     296        queryset = changelist.get_queryset(request)
    297297        self.assertEqual(list(queryset), [self.gipsy_book])
    298298
    299299        # Make sure the last choice is None and is selected
    class ListFiltersTests(TestCase): 
    321321        changelist = self.get_changelist(request, Book, modeladmin)
    322322
    323323        # Make sure the correct queryset is returned
    324         queryset = changelist.get_query_set(request)
     324        queryset = changelist.get_queryset(request)
    325325        self.assertEqual(list(queryset), [self.django_book, self.bio_book, self.djangonaut_book])
    326326
    327327        # Make sure the last choice is None and is selected
    class ListFiltersTests(TestCase): 
    349349        changelist = self.get_changelist(request, User, modeladmin)
    350350
    351351        # Make sure the correct queryset is returned
    352         queryset = changelist.get_query_set(request)
     352        queryset = changelist.get_queryset(request)
    353353        self.assertEqual(list(queryset), [self.lisa])
    354354
    355355        # Make sure the last choice is None and is selected
    class ListFiltersTests(TestCase): 
    374374        changelist = self.get_changelist(request, User, modeladmin)
    375375
    376376        # Make sure the correct queryset is returned
    377         queryset = changelist.get_query_set(request)
     377        queryset = changelist.get_queryset(request)
    378378        self.assertEqual(list(queryset), [self.alfred])
    379379
    380380        # Make sure the last choice is None and is selected
    class ListFiltersTests(TestCase): 
    410410        changelist = self.get_changelist(request, Book, modeladmin)
    411411
    412412        # Make sure the correct queryset is returned
    413         queryset = changelist.get_query_set(request)
     413        queryset = changelist.get_queryset(request)
    414414        self.assertEqual(list(queryset), [self.bio_book])
    415415
    416416        # Make sure the correct choice is selected
    class ListFiltersTests(TestCase): 
    424424        changelist = self.get_changelist(request, Book, modeladmin)
    425425
    426426        # Make sure the correct queryset is returned
    427         queryset = changelist.get_query_set(request)
     427        queryset = changelist.get_queryset(request)
    428428        self.assertEqual(list(queryset), [self.gipsy_book, self.djangonaut_book])
    429429
    430430        # Make sure the correct choice is selected
    class ListFiltersTests(TestCase): 
    438438        changelist = self.get_changelist(request, Book, modeladmin)
    439439
    440440        # Make sure the correct queryset is returned
    441         queryset = changelist.get_query_set(request)
     441        queryset = changelist.get_queryset(request)
    442442        self.assertEqual(list(queryset), [self.django_book])
    443443
    444444        # Make sure the correct choice is selected
    class ListFiltersTests(TestCase): 
    457457        changelist = self.get_changelist(request, Book, modeladmin)
    458458
    459459        # Make sure the correct queryset is returned
    460         queryset = changelist.get_query_set(request)
     460        queryset = changelist.get_queryset(request)
    461461        self.assertEqual(list(queryset), list(Book.objects.all().order_by('-id')))
    462462
    463463        # Make sure the correct choice is selected
    class ListFiltersTests(TestCase): 
    474474        changelist = self.get_changelist(request, Book, modeladmin)
    475475
    476476        # Make sure the correct queryset is returned
    477         queryset = changelist.get_query_set(request)
     477        queryset = changelist.get_queryset(request)
    478478        self.assertEqual(list(queryset), [])
    479479
    480480        # Make sure the correct choice is selected
    class ListFiltersTests(TestCase): 
    491491        changelist = self.get_changelist(request, Book, modeladmin)
    492492
    493493        # Make sure the correct queryset is returned
    494         queryset = changelist.get_query_set(request)
     494        queryset = changelist.get_queryset(request)
    495495        self.assertEqual(list(queryset), [self.bio_book])
    496496
    497497        # Make sure the correct choice is selected
    class ListFiltersTests(TestCase): 
    508508        changelist = self.get_changelist(request, Book, modeladmin)
    509509
    510510        # Make sure the correct queryset is returned
    511         queryset = changelist.get_query_set(request)
     511        queryset = changelist.get_queryset(request)
    512512        self.assertEqual(list(queryset), [self.gipsy_book, self.djangonaut_book])
    513513
    514514        # Make sure the correct choice is selected
    class ListFiltersTests(TestCase): 
    525525        changelist = self.get_changelist(request, Book, modeladmin)
    526526
    527527        # Make sure the correct queryset is returned
    528         queryset = changelist.get_query_set(request)
     528        queryset = changelist.get_queryset(request)
    529529        self.assertEqual(list(queryset), [self.djangonaut_book])
    530530
    531531        # Make sure the correct choices are selected
    class ListFiltersTests(TestCase): 
    615615        changelist = self.get_changelist(request, Book, modeladmin)
    616616
    617617        # Make sure the correct queryset is returned
    618         queryset = changelist.get_query_set(request)
     618        queryset = changelist.get_queryset(request)
    619619        self.assertEqual(list(queryset), [self.bio_book])
    620620
    621621        filterspec = changelist.get_filters(request)[0][-1]
    class ListFiltersTests(TestCase): 
    637637        changelist = self.get_changelist(request, Book, modeladmin)
    638638
    639639        # Make sure the correct queryset is returned
    640         queryset = changelist.get_query_set(request)
     640        queryset = changelist.get_queryset(request)
    641641        self.assertEqual(list(queryset), [self.bio_book])
    642642
    643643        # Make sure the correct choice is selected
    class ListFiltersTests(TestCase): 
    654654        changelist = self.get_changelist(request, Book, modeladmin)
    655655
    656656        # Make sure the correct queryset is returned
    657         queryset = changelist.get_query_set(request)
     657        queryset = changelist.get_queryset(request)
    658658        self.assertEqual(list(queryset), [self.bio_book])
    659659
    660660        # Make sure the correct choice is selected
    class ListFiltersTests(TestCase): 
    676676        request = self.request_factory.get('/', {'department': self.john.pk})
    677677        changelist = self.get_changelist(request, Employee, modeladmin)
    678678
    679         queryset = changelist.get_query_set(request)
     679        queryset = changelist.get_queryset(request)
    680680
    681681        self.assertEqual(list(queryset), [self.john])
    682682
    class ListFiltersTests(TestCase): 
    698698        changelist = self.get_changelist(request, Employee, modeladmin)
    699699
    700700        # Make sure the correct queryset is returned
    701         queryset = changelist.get_query_set(request)
     701        queryset = changelist.get_queryset(request)
    702702        self.assertEqual(list(queryset), [self.jack, self.john])
    703703
    704704        filterspec = changelist.get_filters(request)[0][-1]
    class ListFiltersTests(TestCase): 
    723723        changelist = self.get_changelist(request, Employee, modeladmin)
    724724
    725725        # Make sure the correct queryset is returned
    726         queryset = changelist.get_query_set(request)
     726        queryset = changelist.get_queryset(request)
    727727        self.assertEqual(list(queryset), [self.john])
    728728
    729729        filterspec = changelist.get_filters(request)[0][-1]
  • tests/regressiontests/admin_views/admin.py

    diff --git a/tests/regressiontests/admin_views/admin.py b/tests/regressiontests/admin_views/admin.py
    index 435883e..2d85e54 100644
    a b class PostAdmin(admin.ModelAdmin): 
    417417
    418418
    419419class CustomChangeList(ChangeList):
    420     def get_query_set(self, request):
     420    def get_queryset(self, request):
    421421        return self.root_query_set.filter(pk=9999) # Does not exist
    422422
    423423
  • tests/regressiontests/admin_widgets/models.py

    diff --git a/tests/regressiontests/admin_widgets/models.py b/tests/regressiontests/admin_widgets/models.py
    index 2977b86..ae19d58 100644
    a b class Album(models.Model): 
    3737        return self.name
    3838
    3939class HiddenInventoryManager(models.Manager):
    40     def get_query_set(self):
    41         return super(HiddenInventoryManager, self).get_query_set().filter(hidden=False)
     40    def get_queryset(self):
     41        return super(HiddenInventoryManager, self).get_queryset().filter(hidden=False)
    4242
    4343@python_2_unicode_compatible
    4444class Inventory(models.Model):
  • tests/regressiontests/custom_managers_regress/models.py

    diff --git a/tests/regressiontests/custom_managers_regress/models.py b/tests/regressiontests/custom_managers_regress/models.py
    index 71073f0..95cf6e8 100644
    a b class RestrictedManager(models.Manager): 
    1010    """
    1111    A manager that filters out non-public instances.
    1212    """
    13     def get_query_set(self):
    14         return super(RestrictedManager, self).get_query_set().filter(is_public=True)
     13    def get_queryset(self):
     14        return super(RestrictedManager, self).get_queryset().filter(is_public=True)
    1515
    1616@python_2_unicode_compatible
    1717class RelatedModel(models.Model):
  • tests/regressiontests/managers_regress/models.py

    diff --git a/tests/regressiontests/managers_regress/models.py b/tests/regressiontests/managers_regress/models.py
    index d72970d..d8dd22e 100644
    a b from django.utils.encoding import python_2_unicode_compatible 
    77
    88
    99class OnlyFred(models.Manager):
    10     def get_query_set(self):
    11         return super(OnlyFred, self).get_query_set().filter(name='fred')
     10    def get_queryset(self):
     11        return super(OnlyFred, self).get_queryset().filter(name='fred')
    1212
    1313
    1414class OnlyBarney(models.Manager):
    15     def get_query_set(self):
    16         return super(OnlyBarney, self).get_query_set().filter(name='barney')
     15    def get_queryset(self):
     16        return super(OnlyBarney, self).get_queryset().filter(name='barney')
    1717
    1818
    1919class Value42(models.Manager):
    20     def get_query_set(self):
    21         return super(Value42, self).get_query_set().filter(value=42)
     20    def get_queryset(self):
     21        return super(Value42, self).get_queryset().filter(value=42)
    2222
    2323
    2424class AbstractBase1(models.Model):
  • tests/regressiontests/modeladmin/tests.py

    diff --git a/tests/regressiontests/modeladmin/tests.py b/tests/regressiontests/modeladmin/tests.py
    index b0a1812..2f3eddd 100644
    a b class ValidationTests(unittest.TestCase): 
    10741074                return 'awesomeness'
    10751075            def get_choices(self, request):
    10761076                return (('bit', 'A bit awesome'), ('very', 'Very awesome'), )
    1077             def get_query_set(self, cl, qs):
     1077            def get_queryset(self, cl, qs):
    10781078                return qs
    10791079
    10801080        class ValidationTestModelAdmin(ModelAdmin):
  • tests/regressiontests/queries/models.py

    diff --git a/tests/regressiontests/queries/models.py b/tests/regressiontests/queries/models.py
    index 16583e8..7489aeb 100644
    a b class LoopZ(models.Model): 
    175175
    176176# A model and custom default manager combination.
    177177class CustomManager(models.Manager):
    178     def get_query_set(self):
    179         qs = super(CustomManager, self).get_query_set()
     178    def get_queryset(self):
     179        qs = super(CustomManager, self).get_queryset()
    180180        return qs.filter(public=True, tag__name='t1')
    181181
    182182@python_2_unicode_compatible
    class Detail(models.Model): 
    196196    data = models.CharField(max_length=10)
    197197
    198198class MemberManager(models.Manager):
    199     def get_query_set(self):
    200         return super(MemberManager, self).get_query_set().select_related("details")
     199    def get_queryset(self):
     200        return super(MemberManager, self).get_queryset().select_related("details")
    201201
    202202class Member(models.Model):
    203203    name = models.CharField(max_length=10)
  • tests/regressiontests/reverse_single_related/models.py

    diff --git a/tests/regressiontests/reverse_single_related/models.py b/tests/regressiontests/reverse_single_related/models.py
    index 898be84..30ba345 100644
    a b from django.db import models 
    22
    33
    44class SourceManager(models.Manager):
    5     def get_query_set(self):
    6         return super(SourceManager, self).get_query_set().filter(is_public=True)
     5    def get_queryset(self):
     6        return super(SourceManager, self).get_queryset().filter(is_public=True)
    77
    88class Source(models.Model):
    99    is_public = models.BooleanField()
Back to Top