Thanks for the help, bruno. I'm glad to hear that I wasn't misreading the
documentation in some fashion. I'll apply your suggestions.

Luke

On Thu, Dec 4, 2008 at 2:21 PM, bruno desthuilliers <
[EMAIL PROTECTED]> wrote:

>
>
>
> On 4 déc, 21:39, "Luke Graybill" <[EMAIL PROTECTED]> wrote:
> > I am attempting to use a custom manager for related object access, as
> > documented here<
> http://docs.djangoproject.com/en/dev/topics/db/managers/#using-manage...>,
> > but it does not appear to be working properly. Upon accessing the reverse
> > relationship, I am getting an unfiltered queryset result. Using this
> trimmed
> > down code <http://dpaste.com/hold/96205/>,
>
> invert lines 17 and 18, ie make 'referenced' the first declared object
> manager and 'objects' the second.
>
> And yes, the result you get is not what one would expect reading the
> mentioned doc.
>
> The fact is that is that use_for_related_fields only impacts the other
> side of the relationship, ie Shift.worked_by (but since you didn't
> define a  Custom manager for Employee...). In this side of a OneToMany
> relationship, it's the default manager that is used, and the default
> manager is the first declared one.
>
> HTH
>
> PS : As a side note: the pattern I personnally use is :
>
> class ShiftManager(models.Manager):
>    use_for_related_fields = True
>    def referenced(self):
>        return self.filter(is_dereferenced=False)
>
> e = Employee.objects.get(id=1)
> e.shifts.referenced()
>
> This avoid having to write too many managers....
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to