Hey Martin,

To solve the problem I can think of two reasonable solutions:

class MyManager(models.Manager.from_queryset(MyQuerySet)):
    use_for_related_fields = True

or

class MyModel(models.Model):
    objects = MyQuerySet.as_manager()
    objects.use_for_related_fields = True

After all, as_manager() calls from_queryset() internally.

I don't think a class attribute on the QS class makes much sense since 
as_manager() would be the only place where it is used. An argument to 
as_manager() would make more sense to me, though I'm not convinced this is 
really that much of an improvement.

>From the two suggested solutions above, I'd tend to use the first one.

/Markus

On Wednesday, December 31, 2014 2:47:41 AM UTC+1, Martin Chase wrote:
>
> Hey all,
>
> I make extensive use of managers, and I was excited to start using 
> as_manager for my queryset/manager mashups, but it seems 
> use_for_related_fields isn't a part of as_manager's considerations. I can 
> think of two sensible implementations: pass an argument to as_manager(), or 
> honor a class attr of the same name on the queryset.
>
> Is this a reasonable improvement? Is one of those possible implementations 
> (or a completely different one) better?
>
> Regards,
> Martin Chase
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/a167e890-82e6-43e8-b504-0c8a09efd774%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to