Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » Django
  • » following ManyToManyField related objects [RSS Feed]

#1 Jan. 13, 2011 17:42:36

r.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

following ManyToManyField related objects


I'm using Django version 1.1.2.

I'm trying to find all objects that reference object A.
Object B has a ManyToManyField to A.
Object C has the same, but it uses a defined through table.

When I do:
> related_objs = CollectedObjects()
> A._collect_sub_objects(related_objs)
> classes = related_objs.keys()
> print classes

I get C, but not B.

Any ideas what's wrong? I'm guessing this is a bug, but would like to be
certain :)

Rana


--
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
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#2 Jan. 13, 2011 20:35:31

Marc A.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

following ManyToManyField related objects


On Thu, Jan 13, 2011 at 6:40 PM, ranadave <ranad...@gmail.com> wrote:
> I'm using Django version 1.1.2.
>
> I'm trying to find all objects that reference object A.
> Object B has a ManyToManyField to A.
> Object C has the same, but it uses a defined through table.
>
> When I do:
>> related_objs = CollectedObjects()
>> A._collect_sub_objects(related_objs)
>> classes = related_objs.keys()
>> print classes
>
> I get C, but not B.
>
> Any ideas what's wrong?  I'm guessing this is a bug, but would like to be
> certain :)

I don't have any CollectedObjects function in my django installation,
Could it be possible that this function has been deprectated? btw you
could try to use object._meta.get_all_related_objects() function in
order to get all the related objects.


--
Marc

--
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
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#3 Jan. 17, 2011 15:33:45

r.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

following ManyToManyField related objects


Hi,

Thanks for the reply. I am using an old version of Django so maybe they got
rid of it.

What I have found out is that the object is found if I explicitly define a
through table.

ie:

zzz = models.ManyToManyField('xxx', through = 'zzz.xxx_linked', related_name
= 'xxx_of_zzz', blank = True)

Works but

zzz = models.ManyToManyField('xxx', related_name = 'xxx_of_zzz', blank =
True)

Does not.

Seems like a bug to me.

Rana

--
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
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#4 Jan. 17, 2011 16:07:48

Daniel R.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

following ManyToManyField related objects


On Monday, January 17, 2011 3:33:36 PM UTC, ranadave wrote:
>
> Hi,
>
> Thanks for the reply. I am using an old version of Django so maybe they
> got rid of it.
>
> What I have found out is that the object is found if I explicitly define a
> through table.
>
> ie:
>
> zzz = models.ManyToManyField('xxx', through = 'zzz.xxx_linked',
> related_name = 'xxx_of_zzz', blank = True)
>
> Works but
>
> zzz = models.ManyToManyField('xxx', related_name = 'xxx_of_zzz', blank =
> True)
>
> Does not.
>
> Seems like a bug to me.
>
> Rana
>

It might well be a bug, but _collect_sub_objects is not part of any
published/documented API - as implied by the leading backslash - so you
should not be relying on its behaviour.
--
DR.

--
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
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

  • Root
  • » Django
  • » following ManyToManyField related objects [RSS Feed]

Board footer

Moderator control

Enjoy the 17th of August
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support