Question

I have a model Model with a m2m field :

user = .. fk user
...
watchers = models.ManyToManyField(User, related_name="boardShot_watchers",  null=True)

How do i select all distinct Users involved in this watchers relationship for all my entries of type Model ?

I dont think there is an ORM way to access to intermediary M2M table.

Greg

Was it helpful?

Solution

Not in your current model. If you want to have explicit access to the joining table, you need to make it part of the Django object model. The docs explain how to do this:

http://www.djangoproject.com/documentation/models/m2m_intermediary/

The admin and other django.contrib* components can be configured to treat most fields the same as if they were just model.ManyToMany's. But it will take a little config.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top