Since the consensus as shifted toward not making a break-everything 2.0 I'm 
planning to normalize the queryset methods name early in the 1.6 
development cycle to spot any breakages.

The affected classes are the following:

   - *django.contrib.admin.options.BaseModelAdmin* (*queryset* -­> 
   get_queryset).
   - *django.contrib.admin.views.main.ChangeList* (get_query_set -> 
   get_queryset).
   - django.contrib.comments.templatetags.comments.BaseCommentNode 
   (get_query_set -> get_queryset).
   - 
*django.contrib.contenttypes.generic.GenericForeignKey*(get_prefetch_query_set 
-> get_prefetch_queryset).
   - django.db.models.fields.related.SingleRelatedObjectDescriptor 
   (get_query_set -­­> get_queryset, get_prefetch_query_set -> 
   get_prefetch_queryset).
   - django.db.models.fields.related.ReverseSingleRelatedObjectDescriptor 
   (get_query_set -­­> get_queryset, get_prefetch_query_set -> 
   get_prefetch_queryset).
   - *django.db.models.manager.Manager* (*get_query_set* -­­> get_queryset, 
   get_prefetch_query_set -> get_prefetch_queryset).

And subclasses (*ModelAdmin*, ...) where bold items are part of the 
documented API and "->" stands for rename.

The patch does the following:

   1. Define the new method if missing and complain about it.
   2. Define the old method if missing to assure backwards compatibility.
   3. Complain whenever an old method is called.

As discussed in the ticket <https://code.djangoproject.com/ticket/15363>the 
whole MRO is handled by the patch so mixins should also work correctly. 
The only issue you might encounter is if you defined a custom metaclass for 
one of the classed affected by the rename. The simple fix is to make sure 
your metaclass subclasses the class of the class you're planning to attach 
it to:

class MyManagerBase(Manager.__class__):
    pass

class MyManager(Manager):
    __metaclass__ = MyManagerBase
 

If your code base or library must support both Django > 1.6 and <= 1.6 you 
should define both methods until you drop support for < 1.6:

class MyManager(Manager):
    def get_queryset(self, *args, **kwargs):
        # Do something funky
        # ...

    def get_query_set(self, *args, **kwargs):
        # TODO: Remove when support for Django < 1.6 is dropped.
        return MyManager.get_queryset(self, *args, **kwargs)
 

The pull request can be reviewed 
here<https://github.com/django/django/pull/867>.

I'm planning to commit the proposed fix this week if no major issues are 
raised here or on the ticket.

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-developers?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to