Ticket #15363: ticket-15363-renamed_method_factory

File ticket-15363-renamed_method_factory, 59.0 KB (added by Simon Charette, 12 years ago)
Line 
1diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
2index 8de3112..f429af5 100644
3--- a/django/contrib/admin/options.py
4+++ b/django/contrib/admin/options.py
5@@ -222,7 +222,7 @@ class BaseModelAdmin(six.with_metaclass(forms.MediaDefiningClass)):
6 Returns a QuerySet of all model instances that can be edited by the
7 admin site. This is used by changelist_view.
8 """
9- qs = self.model._default_manager.get_query_set()
10+ qs = self.model._default_manager.get_queryset()
11 # TODO: this should be handled by some parameter to the ChangeList.
12 ordering = self.get_ordering(request)
13 if ordering:
14@@ -1187,7 +1187,7 @@ class ModelAdmin(BaseModelAdmin):
15 if (actions and request.method == 'POST' and
16 'index' in request.POST and '_save' not in request.POST):
17 if selected:
18- response = self.response_action(request, queryset=cl.get_query_set(request))
19+ response = self.response_action(request, queryset=cl.get_queryset(request))
20 if response:
21 return response
22 else:
23@@ -1203,7 +1203,7 @@ class ModelAdmin(BaseModelAdmin):
24 helpers.ACTION_CHECKBOX_NAME in request.POST and
25 'index' not in request.POST and '_save' not in request.POST):
26 if selected:
27- response = self.response_action(request, queryset=cl.get_query_set(request))
28+ response = self.response_action(request, queryset=cl.get_queryset(request))
29 if response:
30 return response
31 else:
32diff --git a/django/contrib/admin/views/main.py b/django/contrib/admin/views/main.py
33index 4b296b3..c45d5d8 100644
34--- a/django/contrib/admin/views/main.py
35+++ b/django/contrib/admin/views/main.py
36@@ -6,7 +6,9 @@ from django.core.paginator import InvalidPage
37 from django.core.urlresolvers import reverse
38 from django.db import models
39 from django.db.models.fields import FieldDoesNotExist
40+from django.utils import six
41 from django.utils.datastructures import SortedDict
42+from django.utils.deprecation import DeprecatedGetQuerySet
43 from django.utils.encoding import force_str, force_text
44 from django.utils.translation import ugettext, ugettext_lazy
45 from django.utils.http import urlencode
46@@ -33,7 +35,7 @@ IGNORED_PARAMS = (
47 EMPTY_CHANGELIST_VALUE = ugettext_lazy('(None)')
48
49
50-class ChangeList(object):
51+class ChangeList(six.with_metaclass(DeprecatedGetQuerySet)):
52 def __init__(self, request, model, list_display, list_display_links,
53 list_filter, date_hierarchy, search_fields, list_select_related,
54 list_per_page, list_max_show_all, list_editable, model_admin):
55@@ -70,7 +72,7 @@ class ChangeList(object):
56 else:
57 self.list_editable = list_editable
58 self.query = request.GET.get(SEARCH_VAR, '')
59- self.query_set = self.get_query_set(request)
60+ self.query_set = self.get_queryset(request)
61 self.get_results(request)
62 if self.is_popup:
63 title = ugettext('Select %s')
64@@ -297,7 +299,7 @@ class ChangeList(object):
65 ordering_fields[idx] = 'desc' if pfx == '-' else 'asc'
66 return ordering_fields
67
68- def get_query_set(self, request):
69+ def get_queryset(self, request):
70 # First, we collect all the declared list filters.
71 (self.filter_specs, self.has_filters, remaining_lookup_params,
72 use_distinct) = self.get_filters(request)
73diff --git a/django/contrib/comments/managers.py b/django/contrib/comments/managers.py
74index bc0fc5f..6562004 100644
75--- a/django/contrib/comments/managers.py
76+++ b/django/contrib/comments/managers.py
77@@ -8,7 +8,7 @@ class CommentManager(models.Manager):
78 """
79 QuerySet for all comments currently in the moderation queue.
80 """
81- return self.get_query_set().filter(is_public=False, is_removed=False)
82+ return self.get_queryset().filter(is_public=False, is_removed=False)
83
84 def for_model(self, model):
85 """
86@@ -16,7 +16,7 @@ class CommentManager(models.Manager):
87 a class).
88 """
89 ct = ContentType.objects.get_for_model(model)
90- qs = self.get_query_set().filter(content_type=ct)
91+ qs = self.get_queryset().filter(content_type=ct)
92 if isinstance(model, models.Model):
93 qs = qs.filter(object_pk=force_text(model._get_pk_val()))
94 return qs
95diff --git a/django/contrib/comments/templatetags/comments.py b/django/contrib/comments/templatetags/comments.py
96index 4d4eb23..900c08f 100644
97--- a/django/contrib/comments/templatetags/comments.py
98+++ b/django/contrib/comments/templatetags/comments.py
99@@ -3,11 +3,14 @@ from django.template.loader import render_to_string
100 from django.conf import settings
101 from django.contrib.contenttypes.models import ContentType
102 from django.contrib import comments
103+from django.utils import six
104+from django.utils.deprecation import DeprecatedGetQuerySet
105 from django.utils.encoding import smart_text
106
107 register = template.Library()
108
109-class BaseCommentNode(template.Node):
110+
111+class BaseCommentNode(six.with_metaclass(DeprecatedGetQuerySet, template.Node)):
112 """
113 Base helper class (abstract) for handling the get_comment_* template tags.
114 Looks a bit strange, but the subclasses below should make this a bit more
115@@ -64,11 +67,11 @@ class BaseCommentNode(template.Node):
116 self.comment = comment
117
118 def render(self, context):
119- qs = self.get_query_set(context)
120+ qs = self.get_queryset(context)
121 context[self.as_varname] = self.get_context_value_from_queryset(context, qs)
122 return ''
123
124- def get_query_set(self, context):
125+ def get_queryset(self, context):
126 ctype, object_pk = self.get_target_ctype_pk(context)
127 if not object_pk:
128 return self.comment_model.objects.none()
129@@ -205,7 +208,7 @@ class RenderCommentListNode(CommentListNode):
130 "comments/%s/list.html" % ctype.app_label,
131 "comments/list.html"
132 ]
133- qs = self.get_query_set(context)
134+ qs = self.get_queryset(context)
135 context.push()
136 liststr = render_to_string(template_search_list, {
137 "comment_list" : self.get_context_value_from_queryset(context, qs)
138diff --git a/django/contrib/contenttypes/generic.py b/django/contrib/contenttypes/generic.py
139index 20ff704..9624964 100644
140--- a/django/contrib/contenttypes/generic.py
141+++ b/django/contrib/contenttypes/generic.py
142@@ -316,12 +316,12 @@ def create_generic_related_manager(superclass):
143 '%s__exact' % object_id_field_name: instance._get_pk_val(),
144 }
145
146- def get_query_set(self):
147+ def get_queryset(self):
148 try:
149 return self.instance._prefetched_objects_cache[self.prefetch_cache_name]
150 except (AttributeError, KeyError):
151 db = self._db or router.db_for_read(self.model, instance=self.instance)
152- return super(GenericRelatedObjectManager, self).get_query_set().using(db).filter(**self.core_filters)
153+ return super(GenericRelatedObjectManager, self).get_queryset().using(db).filter(**self.core_filters)
154
155 def get_prefetch_query_set(self, instances):
156 db = self._db or router.db_for_read(self.model, instance=instances[0])
157@@ -330,7 +330,7 @@ def create_generic_related_manager(superclass):
158 '%s__in' % self.object_id_field_name:
159 set(obj._get_pk_val() for obj in instances)
160 }
161- qs = super(GenericRelatedObjectManager, self).get_query_set().using(db).filter(**query)
162+ qs = super(GenericRelatedObjectManager, self).get_queryset().using(db).filter(**query)
163 # We (possibly) need to convert object IDs to the type of the
164 # instances' PK in order to match up instances:
165 object_id_converter = instances[0]._meta.pk.to_python
166diff --git a/django/contrib/gis/db/models/manager.py b/django/contrib/gis/db/models/manager.py
167index 61fb821..bbcbb57 100644
168--- a/django/contrib/gis/db/models/manager.py
169+++ b/django/contrib/gis/db/models/manager.py
170@@ -1,6 +1,7 @@
171 from django.db.models.manager import Manager
172 from django.contrib.gis.db.models.query import GeoQuerySet
173
174+
175 class GeoManager(Manager):
176 "Overrides Manager to return Geographic QuerySets."
177
178@@ -9,95 +10,95 @@ class GeoManager(Manager):
179 # properly.
180 use_for_related_fields = True
181
182- def get_query_set(self):
183+ def get_queryset(self):
184 return GeoQuerySet(self.model, using=self._db)
185
186 def area(self, *args, **kwargs):
187- return self.get_query_set().area(*args, **kwargs)
188+ return self.get_queryset().area(*args, **kwargs)
189
190 def centroid(self, *args, **kwargs):
191- return self.get_query_set().centroid(*args, **kwargs)
192+ return self.get_queryset().centroid(*args, **kwargs)
193
194 def collect(self, *args, **kwargs):
195- return self.get_query_set().collect(*args, **kwargs)
196+ return self.get_queryset().collect(*args, **kwargs)
197
198 def difference(self, *args, **kwargs):
199- return self.get_query_set().difference(*args, **kwargs)
200+ return self.get_queryset().difference(*args, **kwargs)
201
202 def distance(self, *args, **kwargs):
203- return self.get_query_set().distance(*args, **kwargs)
204+ return self.get_queryset().distance(*args, **kwargs)
205
206 def envelope(self, *args, **kwargs):
207- return self.get_query_set().envelope(*args, **kwargs)
208+ return self.get_queryset().envelope(*args, **kwargs)
209
210 def extent(self, *args, **kwargs):
211- return self.get_query_set().extent(*args, **kwargs)
212+ return self.get_queryset().extent(*args, **kwargs)
213
214 def extent3d(self, *args, **kwargs):
215- return self.get_query_set().extent3d(*args, **kwargs)
216+ return self.get_queryset().extent3d(*args, **kwargs)
217
218 def force_rhr(self, *args, **kwargs):
219- return self.get_query_set().force_rhr(*args, **kwargs)
220+ return self.get_queryset().force_rhr(*args, **kwargs)
221
222 def geohash(self, *args, **kwargs):
223- return self.get_query_set().geohash(*args, **kwargs)
224+ return self.get_queryset().geohash(*args, **kwargs)
225
226 def geojson(self, *args, **kwargs):
227- return self.get_query_set().geojson(*args, **kwargs)
228+ return self.get_queryset().geojson(*args, **kwargs)
229
230 def gml(self, *args, **kwargs):
231- return self.get_query_set().gml(*args, **kwargs)
232+ return self.get_queryset().gml(*args, **kwargs)
233
234 def intersection(self, *args, **kwargs):
235- return self.get_query_set().intersection(*args, **kwargs)
236+ return self.get_queryset().intersection(*args, **kwargs)
237
238 def kml(self, *args, **kwargs):
239- return self.get_query_set().kml(*args, **kwargs)
240+ return self.get_queryset().kml(*args, **kwargs)
241
242 def length(self, *args, **kwargs):
243- return self.get_query_set().length(*args, **kwargs)
244+ return self.get_queryset().length(*args, **kwargs)
245
246 def make_line(self, *args, **kwargs):
247- return self.get_query_set().make_line(*args, **kwargs)
248+ return self.get_queryset().make_line(*args, **kwargs)
249
250 def mem_size(self, *args, **kwargs):
251- return self.get_query_set().mem_size(*args, **kwargs)
252+ return self.get_queryset().mem_size(*args, **kwargs)
253
254 def num_geom(self, *args, **kwargs):
255- return self.get_query_set().num_geom(*args, **kwargs)
256+ return self.get_queryset().num_geom(*args, **kwargs)
257
258 def num_points(self, *args, **kwargs):
259- return self.get_query_set().num_points(*args, **kwargs)
260+ return self.get_queryset().num_points(*args, **kwargs)
261
262 def perimeter(self, *args, **kwargs):
263- return self.get_query_set().perimeter(*args, **kwargs)
264+ return self.get_queryset().perimeter(*args, **kwargs)
265
266 def point_on_surface(self, *args, **kwargs):
267- return self.get_query_set().point_on_surface(*args, **kwargs)
268+ return self.get_queryset().point_on_surface(*args, **kwargs)
269
270 def reverse_geom(self, *args, **kwargs):
271- return self.get_query_set().reverse_geom(*args, **kwargs)
272+ return self.get_queryset().reverse_geom(*args, **kwargs)
273
274 def scale(self, *args, **kwargs):
275- return self.get_query_set().scale(*args, **kwargs)
276+ return self.get_queryset().scale(*args, **kwargs)
277
278 def snap_to_grid(self, *args, **kwargs):
279- return self.get_query_set().snap_to_grid(*args, **kwargs)
280+ return self.get_queryset().snap_to_grid(*args, **kwargs)
281
282 def svg(self, *args, **kwargs):
283- return self.get_query_set().svg(*args, **kwargs)
284+ return self.get_queryset().svg(*args, **kwargs)
285
286 def sym_difference(self, *args, **kwargs):
287- return self.get_query_set().sym_difference(*args, **kwargs)
288+ return self.get_queryset().sym_difference(*args, **kwargs)
289
290 def transform(self, *args, **kwargs):
291- return self.get_query_set().transform(*args, **kwargs)
292+ return self.get_queryset().transform(*args, **kwargs)
293
294 def translate(self, *args, **kwargs):
295- return self.get_query_set().translate(*args, **kwargs)
296+ return self.get_queryset().translate(*args, **kwargs)
297
298 def union(self, *args, **kwargs):
299- return self.get_query_set().union(*args, **kwargs)
300+ return self.get_queryset().union(*args, **kwargs)
301
302 def unionagg(self, *args, **kwargs):
303- return self.get_query_set().unionagg(*args, **kwargs)
304+ return self.get_queryset().unionagg(*args, **kwargs)
305diff --git a/django/contrib/sites/managers.py b/django/contrib/sites/managers.py
306index 3df485a..449e081 100644
307--- a/django/contrib/sites/managers.py
308+++ b/django/contrib/sites/managers.py
309@@ -2,6 +2,7 @@ from django.conf import settings
310 from django.db import models
311 from django.db.models.fields import FieldDoesNotExist
312
313+
314 class CurrentSiteManager(models.Manager):
315 "Use this to limit objects to those associated with the current site."
316 def __init__(self, field_name=None):
317@@ -35,7 +36,7 @@ class CurrentSiteManager(models.Manager):
318 (self.__class__.__name__, self.__field_name, self.model._meta.object_name))
319 self.__is_validated = True
320
321- def get_query_set(self):
322+ def get_queryset(self):
323 if not self.__is_validated:
324 self._validate_field_name()
325- return super(CurrentSiteManager, self).get_query_set().filter(**{self.__field_name + '__id__exact': settings.SITE_ID})
326+ return super(CurrentSiteManager, self).get_queryset().filter(**{self.__field_name + '__id__exact': settings.SITE_ID})
327diff --git a/django/db/models/fields/related.py b/django/db/models/fields/related.py
328index bd2e288..7f2e81c 100644
329--- a/django/db/models/fields/related.py
330+++ b/django/db/models/fields/related.py
331@@ -1,5 +1,7 @@
332 from operator import attrgetter
333
334+from django import forms
335+from django.core import exceptions
336 from django.db import connection, router
337 from django.db.backends import util
338 from django.db.models import signals, get_model
339@@ -11,10 +13,10 @@ from django.db.models.query_utils import QueryWrapper
340 from django.db.models.deletion import CASCADE
341 from django.utils.encoding import smart_text
342 from django.utils import six
343+from django.utils.deprecation import DeprecatedGetQuerySet
344 from django.utils.translation import ugettext_lazy as _, string_concat
345 from django.utils.functional import curry, cached_property
346-from django.core import exceptions
347-from django import forms
348+
349
350 RECURSIVE_RELATIONSHIP_CONSTANT = 'self'
351
352@@ -225,7 +227,7 @@ class RelatedField(object):
353 return self.rel.related_name or self.opts.model_name
354
355
356-class SingleRelatedObjectDescriptor(object):
357+class SingleRelatedObjectDescriptor(six.with_metaclass(DeprecatedGetQuerySet)):
358 # This class provides the functionality that makes the related-object
359 # managers available as attributes on a model class, for fields that have
360 # a single "remote" value, on the class pointed to by a related field.
361@@ -238,7 +240,7 @@ class SingleRelatedObjectDescriptor(object):
362 def is_cached(self, instance):
363 return hasattr(instance, self.cache_name)
364
365- def get_query_set(self, **db_hints):
366+ def get_queryset(self, **db_hints):
367 db = router.db_for_read(self.related.model, **db_hints)
368 return self.related.model._base_manager.using(db)
369
370@@ -247,7 +249,7 @@ class SingleRelatedObjectDescriptor(object):
371 instance_attr = lambda obj: obj._get_pk_val()
372 instances_dict = dict((instance_attr(inst), inst) for inst in instances)
373 params = {'%s__pk__in' % self.related.field.name: list(instances_dict)}
374- qs = self.get_query_set(instance=instances[0]).filter(**params)
375+ qs = self.get_queryset(instance=instances[0]).filter(**params)
376 # Since we're going to assign directly in the cache,
377 # we must manage the reverse relation cache manually.
378 rel_obj_cache_name = self.related.field.get_cache_name()
379@@ -268,7 +270,7 @@ class SingleRelatedObjectDescriptor(object):
380 else:
381 params = {'%s__pk' % self.related.field.name: related_pk}
382 try:
383- rel_obj = self.get_query_set(instance=instance).get(**params)
384+ rel_obj = self.get_queryset(instance=instance).get(**params)
385 except self.related.model.DoesNotExist:
386 rel_obj = None
387 else:
388@@ -321,7 +323,7 @@ class SingleRelatedObjectDescriptor(object):
389 setattr(value, self.related.field.get_cache_name(), instance)
390
391
392-class ReverseSingleRelatedObjectDescriptor(object):
393+class ReverseSingleRelatedObjectDescriptor(six.with_metaclass(DeprecatedGetQuerySet)):
394 # This class provides the functionality that makes the related-object
395 # managers available as attributes on a model class, for fields that have
396 # a single "remote" value, on the class that defines the related field.
397@@ -334,7 +336,7 @@ class ReverseSingleRelatedObjectDescriptor(object):
398 def is_cached(self, instance):
399 return hasattr(instance, self.cache_name)
400
401- def get_query_set(self, **db_hints):
402+ def get_queryset(self, **db_hints):
403 db = router.db_for_read(self.field.rel.to, **db_hints)
404 rel_mgr = self.field.rel.to._default_manager
405 # If the related manager indicates that it should be used for
406@@ -353,7 +355,7 @@ class ReverseSingleRelatedObjectDescriptor(object):
407 params = {'%s__pk__in' % self.field.rel.field_name: list(instances_dict)}
408 else:
409 params = {'%s__in' % self.field.rel.field_name: list(instances_dict)}
410- qs = self.get_query_set(instance=instances[0]).filter(**params)
411+ qs = self.get_queryset(instance=instances[0]).filter(**params)
412 # Since we're going to assign directly in the cache,
413 # we must manage the reverse relation cache manually.
414 if not self.field.rel.multiple:
415@@ -378,7 +380,7 @@ class ReverseSingleRelatedObjectDescriptor(object):
416 params = {'%s__%s' % (self.field.rel.field_name, other_field.rel.field_name): val}
417 else:
418 params = {'%s__exact' % self.field.rel.field_name: val}
419- qs = self.get_query_set(instance=instance)
420+ qs = self.get_queryset(instance=instance)
421 # Assuming the database enforces foreign keys, this won't fail.
422 rel_obj = qs.get(**params)
423 if not self.field.rel.multiple:
424@@ -490,12 +492,12 @@ class ForeignRelatedObjectsDescriptor(object):
425 }
426 self.model = rel_model
427
428- def get_query_set(self):
429+ def get_queryset(self):
430 try:
431 return self.instance._prefetched_objects_cache[rel_field.related_query_name()]
432 except (AttributeError, KeyError):
433 db = self._db or router.db_for_read(self.model, instance=self.instance)
434- qs = super(RelatedManager, self).get_query_set().using(db).filter(**self.core_filters)
435+ qs = super(RelatedManager, self).get_queryset().using(db).filter(**self.core_filters)
436 if getattr(self.instance, attname) is None:
437 return qs.none()
438 qs._known_related_objects = {rel_field: {self.instance.pk: self.instance}}
439@@ -507,7 +509,7 @@ class ForeignRelatedObjectsDescriptor(object):
440 instances_dict = dict((instance_attr(inst), inst) for inst in instances)
441 db = self._db or router.db_for_read(self.model, instance=instances[0])
442 query = {'%s__%s__in' % (rel_field.name, attname): list(instances_dict)}
443- qs = super(RelatedManager, self).get_query_set().using(db).filter(**query)
444+ qs = super(RelatedManager, self).get_queryset().using(db).filter(**query)
445 # Since we just bypassed this class' get_query_set(), we must manage
446 # the reverse relation manually.
447 for rel_obj in qs:
448@@ -602,12 +604,12 @@ def create_many_related_manager(superclass, rel):
449 else:
450 return obj.pk
451
452- def get_query_set(self):
453+ def get_queryset(self):
454 try:
455 return self.instance._prefetched_objects_cache[self.prefetch_cache_name]
456 except (AttributeError, KeyError):
457 db = self._db or router.db_for_read(self.instance.__class__, instance=self.instance)
458- return super(ManyRelatedManager, self).get_query_set().using(db)._next_is_sticky().filter(**self.core_filters)
459+ return super(ManyRelatedManager, self).get_queryset().using(db)._next_is_sticky().filter(**self.core_filters)
460
461 def get_prefetch_query_set(self, instances):
462 instance = instances[0]
463@@ -615,7 +617,7 @@ def create_many_related_manager(superclass, rel):
464 db = self._db or router.db_for_read(instance.__class__, instance=instance)
465 query = {'%s__pk__in' % self.query_field_name:
466 set(obj._get_pk_val() for obj in instances)}
467- qs = super(ManyRelatedManager, self).get_query_set().using(db)._next_is_sticky().filter(**query)
468+ qs = super(ManyRelatedManager, self).get_queryset().using(db)._next_is_sticky().filter(**query)
469
470 # M2M: need to annotate the query in order to get the primary model
471 # that the secondary model was actually related to. We know that
472diff --git a/django/db/models/manager.py b/django/db/models/manager.py
473index cee2131..bc1724c 100644
474--- a/django/db/models/manager.py
475+++ b/django/db/models/manager.py
476@@ -3,6 +3,8 @@ from django.db import router
477 from django.db.models.query import QuerySet, insert_query, RawQuerySet
478 from django.db.models import signals
479 from django.db.models.fields import FieldDoesNotExist
480+from django.utils import six
481+from django.utils.deprecation import DeprecatedGetQuerySet
482
483
484 def ensure_default_manager(sender, **kwargs):
485@@ -47,7 +49,7 @@ def ensure_default_manager(sender, **kwargs):
486 signals.class_prepared.connect(ensure_default_manager)
487
488
489-class Manager(object):
490+class Manager(six.with_metaclass(DeprecatedGetQuerySet)):
491 # Tracks each time a Manager instance is created. Used to retain order.
492 creation_counter = 0
493
494@@ -112,110 +114,110 @@ class Manager(object):
495 # PROXIES TO QUERYSET #
496 #######################
497
498- def get_query_set(self):
499+ def get_queryset(self):
500 """Returns a new QuerySet object. Subclasses can override this method
501 to easily customize the behavior of the Manager.
502 """
503 return QuerySet(self.model, using=self._db)
504
505 def none(self):
506- return self.get_query_set().none()
507+ return self.get_queryset().none()
508
509 def all(self):
510- return self.get_query_set()
511+ return self.get_queryset()
512
513 def count(self):
514- return self.get_query_set().count()
515+ return self.get_queryset().count()
516
517 def dates(self, *args, **kwargs):
518- return self.get_query_set().dates(*args, **kwargs)
519+ return self.get_queryset().dates(*args, **kwargs)
520
521 def distinct(self, *args, **kwargs):
522- return self.get_query_set().distinct(*args, **kwargs)
523+ return self.get_queryset().distinct(*args, **kwargs)
524
525 def extra(self, *args, **kwargs):
526- return self.get_query_set().extra(*args, **kwargs)
527+ return self.get_queryset().extra(*args, **kwargs)
528
529 def get(self, *args, **kwargs):
530- return self.get_query_set().get(*args, **kwargs)
531+ return self.get_queryset().get(*args, **kwargs)
532
533 def get_or_create(self, **kwargs):
534- return self.get_query_set().get_or_create(**kwargs)
535+ return self.get_queryset().get_or_create(**kwargs)
536
537 def create(self, **kwargs):
538- return self.get_query_set().create(**kwargs)
539+ return self.get_queryset().create(**kwargs)
540
541 def bulk_create(self, *args, **kwargs):
542- return self.get_query_set().bulk_create(*args, **kwargs)
543+ return self.get_queryset().bulk_create(*args, **kwargs)
544
545 def filter(self, *args, **kwargs):
546- return self.get_query_set().filter(*args, **kwargs)
547+ return self.get_queryset().filter(*args, **kwargs)
548
549 def aggregate(self, *args, **kwargs):
550- return self.get_query_set().aggregate(*args, **kwargs)
551+ return self.get_queryset().aggregate(*args, **kwargs)
552
553 def annotate(self, *args, **kwargs):
554- return self.get_query_set().annotate(*args, **kwargs)
555+ return self.get_queryset().annotate(*args, **kwargs)
556
557 def complex_filter(self, *args, **kwargs):
558- return self.get_query_set().complex_filter(*args, **kwargs)
559+ return self.get_queryset().complex_filter(*args, **kwargs)
560
561 def exclude(self, *args, **kwargs):
562- return self.get_query_set().exclude(*args, **kwargs)
563+ return self.get_queryset().exclude(*args, **kwargs)
564
565 def in_bulk(self, *args, **kwargs):
566- return self.get_query_set().in_bulk(*args, **kwargs)
567+ return self.get_queryset().in_bulk(*args, **kwargs)
568
569 def iterator(self, *args, **kwargs):
570- return self.get_query_set().iterator(*args, **kwargs)
571+ return self.get_queryset().iterator(*args, **kwargs)
572
573 def earliest(self, *args, **kwargs):
574- return self.get_query_set().earliest(*args, **kwargs)
575+ return self.get_queryset().earliest(*args, **kwargs)
576
577 def latest(self, *args, **kwargs):
578- return self.get_query_set().latest(*args, **kwargs)
579+ return self.get_queryset().latest(*args, **kwargs)
580
581 def order_by(self, *args, **kwargs):
582- return self.get_query_set().order_by(*args, **kwargs)
583+ return self.get_queryset().order_by(*args, **kwargs)
584
585 def select_for_update(self, *args, **kwargs):
586- return self.get_query_set().select_for_update(*args, **kwargs)
587+ return self.get_queryset().select_for_update(*args, **kwargs)
588
589 def select_related(self, *args, **kwargs):
590- return self.get_query_set().select_related(*args, **kwargs)
591+ return self.get_queryset().select_related(*args, **kwargs)
592
593 def prefetch_related(self, *args, **kwargs):
594- return self.get_query_set().prefetch_related(*args, **kwargs)
595+ return self.get_queryset().prefetch_related(*args, **kwargs)
596
597 def values(self, *args, **kwargs):
598- return self.get_query_set().values(*args, **kwargs)
599+ return self.get_queryset().values(*args, **kwargs)
600
601 def values_list(self, *args, **kwargs):
602- return self.get_query_set().values_list(*args, **kwargs)
603+ return self.get_queryset().values_list(*args, **kwargs)
604
605 def update(self, *args, **kwargs):
606- return self.get_query_set().update(*args, **kwargs)
607+ return self.get_queryset().update(*args, **kwargs)
608
609 def reverse(self, *args, **kwargs):
610- return self.get_query_set().reverse(*args, **kwargs)
611+ return self.get_queryset().reverse(*args, **kwargs)
612
613 def defer(self, *args, **kwargs):
614- return self.get_query_set().defer(*args, **kwargs)
615+ return self.get_queryset().defer(*args, **kwargs)
616
617 def only(self, *args, **kwargs):
618- return self.get_query_set().only(*args, **kwargs)
619+ return self.get_queryset().only(*args, **kwargs)
620
621 def using(self, *args, **kwargs):
622- return self.get_query_set().using(*args, **kwargs)
623+ return self.get_queryset().using(*args, **kwargs)
624
625 def exists(self, *args, **kwargs):
626- return self.get_query_set().exists(*args, **kwargs)
627+ return self.get_queryset().exists(*args, **kwargs)
628
629 def _insert(self, objs, fields, **kwargs):
630 return insert_query(self.model, objs, fields, **kwargs)
631
632 def _update(self, values, **kwargs):
633- return self.get_query_set()._update(values, **kwargs)
634+ return self.get_queryset()._update(values, **kwargs)
635
636 def raw(self, raw_query, params=None, *args, **kwargs):
637 return RawQuerySet(raw_query=raw_query, model=self.model, params=params, using=self._db, *args, **kwargs)
638@@ -262,5 +264,5 @@ class EmptyManager(Manager):
639 super(EmptyManager, self).__init__()
640 self.model = model
641
642- def get_query_set(self):
643- return super(EmptyManager, self).get_query_set().none()
644+ def get_queryset(self):
645+ return super(EmptyManager, self).get_queryset().none()
646diff --git a/django/forms/models.py b/django/forms/models.py
647index e2d739f..3948780 100644
648--- a/django/forms/models.py
649+++ b/django/forms/models.py
650@@ -479,7 +479,7 @@ class BaseModelFormSet(BaseFormSet):
651 if self.queryset is not None:
652 qs = self.queryset
653 else:
654- qs = self.model._default_manager.get_query_set()
655+ qs = self.model._default_manager.get_queryset()
656
657 # If the queryset isn't already ordered we need to add an
658 # artificial ordering here to make sure that all formsets
659@@ -674,9 +674,9 @@ class BaseModelFormSet(BaseFormSet):
660 except IndexError:
661 pk_value = None
662 if isinstance(pk, OneToOneField) or isinstance(pk, ForeignKey):
663- qs = pk.rel.to._default_manager.get_query_set()
664+ qs = pk.rel.to._default_manager.get_queryset()
665 else:
666- qs = self.model._default_manager.get_query_set()
667+ qs = self.model._default_manager.get_queryset()
668 qs = qs.using(form.instance._state.db)
669 if form._meta.widgets:
670 widget = form._meta.widgets.get(self._pk_field.name, HiddenInput)
671diff --git a/django/utils/deprecation.py b/django/utils/deprecation.py
672new file mode 100644
673index 0000000..96cefb4
674--- /dev/null
675+++ b/django/utils/deprecation.py
676@@ -0,0 +1,57 @@
677+from __future__ import unicode_literals
678+import warnings
679+
680+from django.core.exceptions import ImproperlyConfigured
681+from django.utils.unittest.compatibility import wraps
682+
683+
684+def renamed_method_factory(old, new, warning=PendingDeprecationWarning):
685+ """
686+ Create a type to handle the deprecation path of a renamed method.
687+
688+ Does the following:
689+ 1) Issue a warning on class creation if `old` is defined.
690+ 2) Raise an `ImproperlyConfigured` error if both `old` and
691+ `new` are defined.
692+ 3) Define a `new` method if not present.
693+ 4) Define or wrap the existing `old` to complain when called.
694+ """
695+ def renamed_method_complain(name, deprecated):
696+ @wraps(deprecated)
697+ def complain(*args, **kwargs):
698+ warnings.warn(
699+ "`%s.%s` is deprecated, use "
700+ "`%s` instead." % (name, old, new),
701+ warning, 2)
702+ return deprecated(*args, **kwargs)
703+ return complain
704+ class RenamedMethod(type):
705+ def __new__(cls, name, bases, attrs):
706+ deprecated = attrs.get(old)
707+ renamed = attrs.get(new)
708+ if deprecated:
709+ if renamed:
710+ raise ImproperlyConfigured(
711+ "'Class `%s` should either define `%s` or "
712+ "`%s` not both.'" % (name, new, old))
713+ else:
714+ attrs[new] = deprecated
715+ warnings.warn(
716+ "`%s.%s` method should be "
717+ "renamed `%s`." % (name, old, new),
718+ warning, 2)
719+ deprecated = renamed_method_complain(name, deprecated)
720+ elif renamed:
721+ deprecated = renamed_method_complain(name, renamed)
722+ if deprecated:
723+ attrs[old] = deprecated
724+ type_ = type.__new__(cls, name, bases, attrs)
725+ # TODO: Handle type_.__mro__ to look for possible mixins
726+ return type_
727+ return RenamedMethod
728+
729+
730+# See #15363 for more details.
731+DeprecatedGetQuerySet = renamed_method_factory('get_query_set', 'get_queryset')
732+#DeprecatedGetPrefetchQuerySet = renamed_method_factory('get_prefetch_query_set', 'get_prefetch_queryset')
733+#DeprecatedQueryset = renamed_method_factory('queryset', 'get_queryset')
734diff --git a/tests/modeltests/custom_managers/models.py b/tests/modeltests/custom_managers/models.py
735index de7c177..2f5e62f 100644
736--- a/tests/modeltests/custom_managers/models.py
737+++ b/tests/modeltests/custom_managers/models.py
738@@ -30,11 +30,11 @@ class Person(models.Model):
739 def __str__(self):
740 return "%s %s" % (self.first_name, self.last_name)
741
742-# An example of a custom manager that sets get_query_set().
743+# An example of a custom manager that sets get_queryset().
744
745 class PublishedBookManager(models.Manager):
746- def get_query_set(self):
747- return super(PublishedBookManager, self).get_query_set().filter(is_published=True)
748+ def get_queryset(self):
749+ return super(PublishedBookManager, self).get_queryset().filter(is_published=True)
750
751 @python_2_unicode_compatible
752 class Book(models.Model):
753@@ -50,8 +50,8 @@ class Book(models.Model):
754 # An example of providing multiple custom managers.
755
756 class FastCarManager(models.Manager):
757- def get_query_set(self):
758- return super(FastCarManager, self).get_query_set().filter(top_speed__gt=150)
759+ def get_queryset(self):
760+ return super(FastCarManager, self).get_queryset().filter(top_speed__gt=150)
761
762 @python_2_unicode_compatible
763 class Car(models.Model):
764diff --git a/tests/modeltests/fixtures/models.py b/tests/modeltests/fixtures/models.py
765index 8bd3501..976716f 100644
766--- a/tests/modeltests/fixtures/models.py
767+++ b/tests/modeltests/fixtures/models.py
768@@ -78,8 +78,8 @@ class Person(models.Model):
769 return (self.name,)
770
771 class SpyManager(PersonManager):
772- def get_query_set(self):
773- return super(SpyManager, self).get_query_set().filter(cover_blown=False)
774+ def get_queryset(self):
775+ return super(SpyManager, self).get_queryset().filter(cover_blown=False)
776
777 class Spy(Person):
778 objects = SpyManager()
779diff --git a/tests/modeltests/generic_relations/models.py b/tests/modeltests/generic_relations/models.py
780index 18d7623..34dc8d3 100644
781--- a/tests/modeltests/generic_relations/models.py
782+++ b/tests/modeltests/generic_relations/models.py
783@@ -88,8 +88,8 @@ class Mineral(models.Model):
784 return self.name
785
786 class GeckoManager(models.Manager):
787- def get_query_set(self):
788- return super(GeckoManager, self).get_query_set().filter(has_tail=True)
789+ def get_queryset(self):
790+ return super(GeckoManager, self).get_queryset().filter(has_tail=True)
791
792 class Gecko(models.Model):
793 has_tail = models.BooleanField()
794diff --git a/tests/modeltests/get_object_or_404/models.py b/tests/modeltests/get_object_or_404/models.py
795index bda0605..bb9aa60 100644
796--- a/tests/modeltests/get_object_or_404/models.py
797+++ b/tests/modeltests/get_object_or_404/models.py
798@@ -22,8 +22,8 @@ class Author(models.Model):
799 return self.name
800
801 class ArticleManager(models.Manager):
802- def get_query_set(self):
803- return super(ArticleManager, self).get_query_set().filter(authors__name__icontains='sir')
804+ def get_queryset(self):
805+ return super(ArticleManager, self).get_queryset().filter(authors__name__icontains='sir')
806
807 @python_2_unicode_compatible
808 class Article(models.Model):
809diff --git a/tests/modeltests/prefetch_related/models.py b/tests/modeltests/prefetch_related/models.py
810index e58997d..81c5698 100644
811--- a/tests/modeltests/prefetch_related/models.py
812+++ b/tests/modeltests/prefetch_related/models.py
813@@ -87,8 +87,8 @@ class Qualification(models.Model):
814
815
816 class TeacherManager(models.Manager):
817- def get_query_set(self):
818- return super(TeacherManager, self).get_query_set().prefetch_related('qualifications')
819+ def get_queryset(self):
820+ return super(TeacherManager, self).get_queryset().prefetch_related('qualifications')
821
822
823 @python_2_unicode_compatible
824diff --git a/tests/modeltests/proxy_models/models.py b/tests/modeltests/proxy_models/models.py
825index 6c962aa..ffb3665 100644
826--- a/tests/modeltests/proxy_models/models.py
827+++ b/tests/modeltests/proxy_models/models.py
828@@ -10,12 +10,12 @@ from django.utils.encoding import python_2_unicode_compatible
829 # A couple of managers for testing managing overriding in proxy model cases.
830
831 class PersonManager(models.Manager):
832- def get_query_set(self):
833- return super(PersonManager, self).get_query_set().exclude(name="fred")
834+ def get_queryset(self):
835+ return super(PersonManager, self).get_queryset().exclude(name="fred")
836
837 class SubManager(models.Manager):
838- def get_query_set(self):
839- return super(SubManager, self).get_query_set().exclude(name="wilma")
840+ def get_queryset(self):
841+ return super(SubManager, self).get_queryset().exclude(name="wilma")
842
843 @python_2_unicode_compatible
844 class Person(models.Model):
845diff --git a/tests/regressiontests/admin_changelist/models.py b/tests/regressiontests/admin_changelist/models.py
846index 4ba2f9c..786b438 100644
847--- a/tests/regressiontests/admin_changelist/models.py
848+++ b/tests/regressiontests/admin_changelist/models.py
849@@ -74,8 +74,8 @@ class UnorderedObject(models.Model):
850
851
852 class OrderedObjectManager(models.Manager):
853- def get_query_set(self):
854- return super(OrderedObjectManager, self).get_query_set().order_by('number')
855+ def get_queryset(self):
856+ return super(OrderedObjectManager, self).get_queryset().order_by('number')
857
858 class OrderedObject(models.Model):
859 """
860diff --git a/tests/regressiontests/admin_changelist/tests.py b/tests/regressiontests/admin_changelist/tests.py
861index 7a3a5c0..2f94cc7 100644
862--- a/tests/regressiontests/admin_changelist/tests.py
863+++ b/tests/regressiontests/admin_changelist/tests.py
864@@ -39,7 +39,7 @@ class ChangeListTests(TestCase):
865
866 def test_select_related_preserved(self):
867 """
868- Regression test for #10348: ChangeList.get_query_set() shouldn't
869+ Regression test for #10348: ChangeList.get_queryset() shouldn't
870 overwrite a custom select_related provided by ModelAdmin.queryset().
871 """
872 m = ChildAdmin(Child, admin.site)
873diff --git a/tests/regressiontests/admin_filters/tests.py b/tests/regressiontests/admin_filters/tests.py
874index 11f792e..d25c8f4 100644
875--- a/tests/regressiontests/admin_filters/tests.py
876+++ b/tests/regressiontests/admin_filters/tests.py
877@@ -183,7 +183,7 @@ class ListFiltersTests(TestCase):
878 changelist = self.get_changelist(request, Book, modeladmin)
879
880 # Make sure the correct queryset is returned
881- queryset = changelist.get_query_set(request)
882+ queryset = changelist.get_queryset(request)
883 self.assertEqual(list(queryset), [self.django_book, self.djangonaut_book])
884
885 # Make sure the correct choice is selected
886@@ -200,7 +200,7 @@ class ListFiltersTests(TestCase):
887 changelist = self.get_changelist(request, Book, modeladmin)
888
889 # Make sure the correct queryset is returned
890- queryset = changelist.get_query_set(request)
891+ queryset = changelist.get_queryset(request)
892 if (self.today.year, self.today.month) == (self.one_week_ago.year, self.one_week_ago.month):
893 # In case one week ago is in the same month.
894 self.assertEqual(list(queryset), [self.gipsy_book, self.django_book, self.djangonaut_book])
895@@ -221,7 +221,7 @@ class ListFiltersTests(TestCase):
896 changelist = self.get_changelist(request, Book, modeladmin)
897
898 # Make sure the correct queryset is returned
899- queryset = changelist.get_query_set(request)
900+ queryset = changelist.get_queryset(request)
901 if self.today.year == self.one_week_ago.year:
902 # In case one week ago is in the same year.
903 self.assertEqual(list(queryset), [self.gipsy_book, self.django_book, self.djangonaut_book])
904@@ -242,7 +242,7 @@ class ListFiltersTests(TestCase):
905 changelist = self.get_changelist(request, Book, modeladmin)
906
907 # Make sure the correct queryset is returned
908- queryset = changelist.get_query_set(request)
909+ queryset = changelist.get_queryset(request)
910 self.assertEqual(list(queryset), [self.gipsy_book, self.django_book, self.djangonaut_book])
911
912 # Make sure the correct choice is selected
913@@ -266,7 +266,7 @@ class ListFiltersTests(TestCase):
914 changelist = self.get_changelist(request, Book, modeladmin)
915
916 # Make sure the correct queryset is returned
917- queryset = changelist.get_query_set(request)
918+ queryset = changelist.get_queryset(request)
919 self.assertEqual(list(queryset), [self.django_book])
920
921 # Make sure the last choice is None and is selected
922@@ -293,7 +293,7 @@ class ListFiltersTests(TestCase):
923 changelist = self.get_changelist(request, Book, modeladmin)
924
925 # Make sure the correct queryset is returned
926- queryset = changelist.get_query_set(request)
927+ queryset = changelist.get_queryset(request)
928 self.assertEqual(list(queryset), [self.gipsy_book])
929
930 # Make sure the last choice is None and is selected
931@@ -321,7 +321,7 @@ class ListFiltersTests(TestCase):
932 changelist = self.get_changelist(request, Book, modeladmin)
933
934 # Make sure the correct queryset is returned
935- queryset = changelist.get_query_set(request)
936+ queryset = changelist.get_queryset(request)
937 self.assertEqual(list(queryset), [self.django_book, self.bio_book, self.djangonaut_book])
938
939 # Make sure the last choice is None and is selected
940@@ -349,7 +349,7 @@ class ListFiltersTests(TestCase):
941 changelist = self.get_changelist(request, User, modeladmin)
942
943 # Make sure the correct queryset is returned
944- queryset = changelist.get_query_set(request)
945+ queryset = changelist.get_queryset(request)
946 self.assertEqual(list(queryset), [self.lisa])
947
948 # Make sure the last choice is None and is selected
949@@ -374,7 +374,7 @@ class ListFiltersTests(TestCase):
950 changelist = self.get_changelist(request, User, modeladmin)
951
952 # Make sure the correct queryset is returned
953- queryset = changelist.get_query_set(request)
954+ queryset = changelist.get_queryset(request)
955 self.assertEqual(list(queryset), [self.alfred])
956
957 # Make sure the last choice is None and is selected
958@@ -410,7 +410,7 @@ class ListFiltersTests(TestCase):
959 changelist = self.get_changelist(request, Book, modeladmin)
960
961 # Make sure the correct queryset is returned
962- queryset = changelist.get_query_set(request)
963+ queryset = changelist.get_queryset(request)
964 self.assertEqual(list(queryset), [self.bio_book])
965
966 # Make sure the correct choice is selected
967@@ -424,7 +424,7 @@ class ListFiltersTests(TestCase):
968 changelist = self.get_changelist(request, Book, modeladmin)
969
970 # Make sure the correct queryset is returned
971- queryset = changelist.get_query_set(request)
972+ queryset = changelist.get_queryset(request)
973 self.assertEqual(list(queryset), [self.gipsy_book, self.djangonaut_book])
974
975 # Make sure the correct choice is selected
976@@ -438,7 +438,7 @@ class ListFiltersTests(TestCase):
977 changelist = self.get_changelist(request, Book, modeladmin)
978
979 # Make sure the correct queryset is returned
980- queryset = changelist.get_query_set(request)
981+ queryset = changelist.get_queryset(request)
982 self.assertEqual(list(queryset), [self.django_book])
983
984 # Make sure the correct choice is selected
985@@ -457,7 +457,7 @@ class ListFiltersTests(TestCase):
986 changelist = self.get_changelist(request, Book, modeladmin)
987
988 # Make sure the correct queryset is returned
989- queryset = changelist.get_query_set(request)
990+ queryset = changelist.get_queryset(request)
991 self.assertEqual(list(queryset), list(Book.objects.all().order_by('-id')))
992
993 # Make sure the correct choice is selected
994@@ -474,7 +474,7 @@ class ListFiltersTests(TestCase):
995 changelist = self.get_changelist(request, Book, modeladmin)
996
997 # Make sure the correct queryset is returned
998- queryset = changelist.get_query_set(request)
999+ queryset = changelist.get_queryset(request)
1000 self.assertEqual(list(queryset), [])
1001
1002 # Make sure the correct choice is selected
1003@@ -491,7 +491,7 @@ class ListFiltersTests(TestCase):
1004 changelist = self.get_changelist(request, Book, modeladmin)
1005
1006 # Make sure the correct queryset is returned
1007- queryset = changelist.get_query_set(request)
1008+ queryset = changelist.get_queryset(request)
1009 self.assertEqual(list(queryset), [self.bio_book])
1010
1011 # Make sure the correct choice is selected
1012@@ -508,7 +508,7 @@ class ListFiltersTests(TestCase):
1013 changelist = self.get_changelist(request, Book, modeladmin)
1014
1015 # Make sure the correct queryset is returned
1016- queryset = changelist.get_query_set(request)
1017+ queryset = changelist.get_queryset(request)
1018 self.assertEqual(list(queryset), [self.gipsy_book, self.djangonaut_book])
1019
1020 # Make sure the correct choice is selected
1021@@ -525,7 +525,7 @@ class ListFiltersTests(TestCase):
1022 changelist = self.get_changelist(request, Book, modeladmin)
1023
1024 # Make sure the correct queryset is returned
1025- queryset = changelist.get_query_set(request)
1026+ queryset = changelist.get_queryset(request)
1027 self.assertEqual(list(queryset), [self.djangonaut_book])
1028
1029 # Make sure the correct choices are selected
1030@@ -615,7 +615,7 @@ class ListFiltersTests(TestCase):
1031 changelist = self.get_changelist(request, Book, modeladmin)
1032
1033 # Make sure the correct queryset is returned
1034- queryset = changelist.get_query_set(request)
1035+ queryset = changelist.get_queryset(request)
1036 self.assertEqual(list(queryset), [self.bio_book])
1037
1038 filterspec = changelist.get_filters(request)[0][-1]
1039@@ -637,7 +637,7 @@ class ListFiltersTests(TestCase):
1040 changelist = self.get_changelist(request, Book, modeladmin)
1041
1042 # Make sure the correct queryset is returned
1043- queryset = changelist.get_query_set(request)
1044+ queryset = changelist.get_queryset(request)
1045 self.assertEqual(list(queryset), [self.bio_book])
1046
1047 # Make sure the correct choice is selected
1048@@ -654,7 +654,7 @@ class ListFiltersTests(TestCase):
1049 changelist = self.get_changelist(request, Book, modeladmin)
1050
1051 # Make sure the correct queryset is returned
1052- queryset = changelist.get_query_set(request)
1053+ queryset = changelist.get_queryset(request)
1054 self.assertEqual(list(queryset), [self.bio_book])
1055
1056 # Make sure the correct choice is selected
1057@@ -676,7 +676,7 @@ class ListFiltersTests(TestCase):
1058 request = self.request_factory.get('/', {'department': self.john.pk})
1059 changelist = self.get_changelist(request, Employee, modeladmin)
1060
1061- queryset = changelist.get_query_set(request)
1062+ queryset = changelist.get_queryset(request)
1063
1064 self.assertEqual(list(queryset), [self.john])
1065
1066@@ -698,7 +698,7 @@ class ListFiltersTests(TestCase):
1067 changelist = self.get_changelist(request, Employee, modeladmin)
1068
1069 # Make sure the correct queryset is returned
1070- queryset = changelist.get_query_set(request)
1071+ queryset = changelist.get_queryset(request)
1072 self.assertEqual(list(queryset), [self.jack, self.john])
1073
1074 filterspec = changelist.get_filters(request)[0][-1]
1075@@ -723,7 +723,7 @@ class ListFiltersTests(TestCase):
1076 changelist = self.get_changelist(request, Employee, modeladmin)
1077
1078 # Make sure the correct queryset is returned
1079- queryset = changelist.get_query_set(request)
1080+ queryset = changelist.get_queryset(request)
1081 self.assertEqual(list(queryset), [self.john])
1082
1083 filterspec = changelist.get_filters(request)[0][-1]
1084diff --git a/tests/regressiontests/admin_views/admin.py b/tests/regressiontests/admin_views/admin.py
1085index 435883e..2d85e54 100644
1086--- a/tests/regressiontests/admin_views/admin.py
1087+++ b/tests/regressiontests/admin_views/admin.py
1088@@ -417,7 +417,7 @@ class PostAdmin(admin.ModelAdmin):
1089
1090
1091 class CustomChangeList(ChangeList):
1092- def get_query_set(self, request):
1093+ def get_queryset(self, request):
1094 return self.root_query_set.filter(pk=9999) # Does not exist
1095
1096
1097diff --git a/tests/regressiontests/admin_widgets/models.py b/tests/regressiontests/admin_widgets/models.py
1098index 2977b86..ae19d58 100644
1099--- a/tests/regressiontests/admin_widgets/models.py
1100+++ b/tests/regressiontests/admin_widgets/models.py
1101@@ -37,8 +37,8 @@ class Album(models.Model):
1102 return self.name
1103
1104 class HiddenInventoryManager(models.Manager):
1105- def get_query_set(self):
1106- return super(HiddenInventoryManager, self).get_query_set().filter(hidden=False)
1107+ def get_queryset(self):
1108+ return super(HiddenInventoryManager, self).get_queryset().filter(hidden=False)
1109
1110 @python_2_unicode_compatible
1111 class Inventory(models.Model):
1112diff --git a/tests/regressiontests/custom_managers_regress/models.py b/tests/regressiontests/custom_managers_regress/models.py
1113index 71073f0..95cf6e8 100644
1114--- a/tests/regressiontests/custom_managers_regress/models.py
1115+++ b/tests/regressiontests/custom_managers_regress/models.py
1116@@ -10,8 +10,8 @@ class RestrictedManager(models.Manager):
1117 """
1118 A manager that filters out non-public instances.
1119 """
1120- def get_query_set(self):
1121- return super(RestrictedManager, self).get_query_set().filter(is_public=True)
1122+ def get_queryset(self):
1123+ return super(RestrictedManager, self).get_queryset().filter(is_public=True)
1124
1125 @python_2_unicode_compatible
1126 class RelatedModel(models.Model):
1127diff --git a/tests/regressiontests/deprecation/__init__.py b/tests/regressiontests/deprecation/__init__.py
1128new file mode 100644
1129index 0000000..e69de29
1130diff --git a/tests/regressiontests/deprecation/models.py b/tests/regressiontests/deprecation/models.py
1131new file mode 100644
1132index 0000000..e69de29
1133diff --git a/tests/regressiontests/deprecation/tests.py b/tests/regressiontests/deprecation/tests.py
1134new file mode 100644
1135index 0000000..32d5a8a
1136--- /dev/null
1137+++ b/tests/regressiontests/deprecation/tests.py
1138@@ -0,0 +1,130 @@
1139+from __future__ import unicode_literals
1140+import warnings
1141+
1142+from django.test.testcases import SimpleTestCase
1143+from django.utils import six
1144+from django.utils.deprecation import renamed_method_factory
1145+from django.core.exceptions import ImproperlyConfigured
1146+
1147+
1148+RenamedMethod = renamed_method_factory('old', 'new')
1149+
1150+
1151+class RenamedMethodTest(SimpleTestCase):
1152+ def test_class_definition_warnings(self):
1153+ """
1154+ Ensure a warning is raised upon class definition to suggest renaming
1155+ the faulty method.
1156+ """
1157+ with warnings.catch_warnings(record=True) as recorded:
1158+ warnings.simplefilter('always')
1159+ class Manager(six.with_metaclass(RenamedMethod)):
1160+ def old(self):
1161+ pass
1162+ self.assertEqual(len(recorded), 1)
1163+ msg = str(recorded[0].message)
1164+ self.assertEqual(msg,
1165+ '`Manager.old` method should be renamed `new`.')
1166+
1167+ def test_new_defined(self):
1168+ """
1169+ Ensure `old` complains and not `new` when only
1170+ `new` is defined.
1171+ """
1172+ with warnings.catch_warnings(record=True) as recorded:
1173+ warnings.simplefilter('ignore')
1174+ class Manager(six.with_metaclass(RenamedMethod)):
1175+ def new(self):
1176+ pass
1177+ warnings.simplefilter('always')
1178+ manager = Manager()
1179+ manager.new()
1180+ self.assertEqual(len(recorded), 0)
1181+ manager.old()
1182+ self.assertEqual(len(recorded), 1)
1183+ msg = str(recorded.pop().message)
1184+ self.assertEqual(msg,
1185+ '`Manager.old` is deprecated, use `new` instead.')
1186+
1187+ def test_old_defined(self):
1188+ """
1189+ Ensure `old` complains and not `new` when only
1190+ `old` is defined.
1191+ """
1192+ with warnings.catch_warnings(record=True) as recorded:
1193+ warnings.simplefilter('ignore')
1194+ class Manager(six.with_metaclass(RenamedMethod)):
1195+ def old(self):
1196+ pass
1197+ warnings.simplefilter('always')
1198+ manager = Manager()
1199+ manager.new()
1200+ self.assertEqual(len(recorded), 0)
1201+ manager.old()
1202+ self.assertEqual(len(recorded), 1)
1203+ msg = str(recorded.pop().message)
1204+ self.assertEqual(msg,
1205+ '`Manager.old` is deprecated, use `new` instead.')
1206+
1207+ def test_deprecated_subclass_renamed(self):
1208+ """
1209+ Ensure the correct warnings are raised when a class that didn't rename
1210+ `old` subclass one that did.
1211+ """
1212+ with warnings.catch_warnings(record=True) as recorded:
1213+ warnings.simplefilter('ignore')
1214+ class Renamed(six.with_metaclass(RenamedMethod)):
1215+ def new(self):
1216+ pass
1217+ class Deprecated(Renamed):
1218+ def old(self):
1219+ super(Deprecated, self).old()
1220+ warnings.simplefilter('always')
1221+ deprecated = Deprecated()
1222+ deprecated.new()
1223+ self.assertEqual(len(recorded), 1)
1224+ msg = str(recorded.pop().message)
1225+ self.assertEqual(msg,
1226+ '`Renamed.old` is deprecated, use `new` instead.')
1227+ deprecated.old()
1228+ self.assertEqual(len(recorded), 2)
1229+ msgs = [str(warning.message) for warning in recorded]
1230+ self.assertEqual(msgs, [
1231+ '`Deprecated.old` is deprecated, use `new` instead.',
1232+ '`Renamed.old` is deprecated, use `new` instead.'])
1233+
1234+ def test_renamed_subclass_deprecated(self):
1235+ """
1236+ Ensure the correct warnings are raised when a class that renamed
1237+ `old` subclass one that didn't.
1238+ """
1239+ with warnings.catch_warnings(record=True) as recorded:
1240+ warnings.simplefilter('ignore')
1241+ class Deprecated(six.with_metaclass(RenamedMethod)):
1242+ def old(self):
1243+ pass
1244+ class Renamed(Deprecated):
1245+ def new(self):
1246+ super(Renamed, self).new()
1247+ warnings.simplefilter('always')
1248+ renamed = Renamed()
1249+ renamed.new()
1250+ self.assertEqual(len(recorded), 0)
1251+ renamed.old()
1252+ self.assertEqual(len(recorded), 1)
1253+ msg = str(recorded.pop().message)
1254+ self.assertEqual(msg,
1255+ '`Renamed.old` is deprecated, use `new` instead.')
1256+
1257+ def test_improperly_configured(self):
1258+ """
1259+ Ensure a significant `ImproperlyConfigured` error is raised when
1260+ both `new` and `old` are defined.
1261+ """
1262+ msg = 'Class `Manager` should either define `new` or `old` not both.'
1263+ with self.assertRaisesMessage(ImproperlyConfigured, msg):
1264+ class Manager(six.with_metaclass(RenamedMethod)):
1265+ def new(self):
1266+ pass
1267+ def old(self):
1268+ pass
1269\ No newline at end of file
1270diff --git a/tests/regressiontests/managers_regress/models.py b/tests/regressiontests/managers_regress/models.py
1271index d72970d..d8dd22e 100644
1272--- a/tests/regressiontests/managers_regress/models.py
1273+++ b/tests/regressiontests/managers_regress/models.py
1274@@ -7,18 +7,18 @@ from django.utils.encoding import python_2_unicode_compatible
1275
1276
1277 class OnlyFred(models.Manager):
1278- def get_query_set(self):
1279- return super(OnlyFred, self).get_query_set().filter(name='fred')
1280+ def get_queryset(self):
1281+ return super(OnlyFred, self).get_queryset().filter(name='fred')
1282
1283
1284 class OnlyBarney(models.Manager):
1285- def get_query_set(self):
1286- return super(OnlyBarney, self).get_query_set().filter(name='barney')
1287+ def get_queryset(self):
1288+ return super(OnlyBarney, self).get_queryset().filter(name='barney')
1289
1290
1291 class Value42(models.Manager):
1292- def get_query_set(self):
1293- return super(Value42, self).get_query_set().filter(value=42)
1294+ def get_queryset(self):
1295+ return super(Value42, self).get_queryset().filter(value=42)
1296
1297
1298 class AbstractBase1(models.Model):
1299diff --git a/tests/regressiontests/modeladmin/tests.py b/tests/regressiontests/modeladmin/tests.py
1300index b0a1812..2f3eddd 100644
1301--- a/tests/regressiontests/modeladmin/tests.py
1302+++ b/tests/regressiontests/modeladmin/tests.py
1303@@ -1074,7 +1074,7 @@ class ValidationTests(unittest.TestCase):
1304 return 'awesomeness'
1305 def get_choices(self, request):
1306 return (('bit', 'A bit awesome'), ('very', 'Very awesome'), )
1307- def get_query_set(self, cl, qs):
1308+ def get_queryset(self, cl, qs):
1309 return qs
1310
1311 class ValidationTestModelAdmin(ModelAdmin):
1312diff --git a/tests/regressiontests/queries/models.py b/tests/regressiontests/queries/models.py
1313index 16583e8..7489aeb 100644
1314--- a/tests/regressiontests/queries/models.py
1315+++ b/tests/regressiontests/queries/models.py
1316@@ -175,8 +175,8 @@ class LoopZ(models.Model):
1317
1318 # A model and custom default manager combination.
1319 class CustomManager(models.Manager):
1320- def get_query_set(self):
1321- qs = super(CustomManager, self).get_query_set()
1322+ def get_queryset(self):
1323+ qs = super(CustomManager, self).get_queryset()
1324 return qs.filter(public=True, tag__name='t1')
1325
1326 @python_2_unicode_compatible
1327@@ -196,8 +196,8 @@ class Detail(models.Model):
1328 data = models.CharField(max_length=10)
1329
1330 class MemberManager(models.Manager):
1331- def get_query_set(self):
1332- return super(MemberManager, self).get_query_set().select_related("details")
1333+ def get_queryset(self):
1334+ return super(MemberManager, self).get_queryset().select_related("details")
1335
1336 class Member(models.Model):
1337 name = models.CharField(max_length=10)
1338diff --git a/tests/regressiontests/reverse_single_related/models.py b/tests/regressiontests/reverse_single_related/models.py
1339index 898be84..30ba345 100644
1340--- a/tests/regressiontests/reverse_single_related/models.py
1341+++ b/tests/regressiontests/reverse_single_related/models.py
1342@@ -2,8 +2,8 @@ from django.db import models
1343
1344
1345 class SourceManager(models.Manager):
1346- def get_query_set(self):
1347- return super(SourceManager, self).get_query_set().filter(is_public=True)
1348+ def get_queryset(self):
1349+ return super(SourceManager, self).get_queryset().filter(is_public=True)
1350
1351 class Source(models.Model):
1352 is_public = models.BooleanField()
Back to Top