Wednesday, February 1, 2012

ManyRelatedManager reference

I can't find a reference for ManyRelatedManager in the django docs. I have
a few questions that you can ignore if there is in fact a reference somewhere
and you can point me to it.

If my model is

class Model(models.Model):
many = models.ManyToManyField(OtherModel)


what does this do?
Model.objects.filter(many = instance_of_other_model)

why do these not work, and what is the correct way to do it?
instance_of_model.many = another_instance.many
instance_of_model.many.add(another_instance.many)

If I have two instances of OtherModel, how do construct a queryset that
matches all instances of Model that reference both?

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

No comments:

Post a Comment