Thursday, September 29, 2011

Re: ManyToMany problem

On Thu, Sep 29, 2011 at 5:20 PM, James DeMichele
<james.demichele@redfin.com> wrote:
> Thanks for the response, that's a completely inaccurate statement.
>
> Here's an example from the Django docs:
>
> https://docs.djangoproject.com/en/1.3/topics/db/models/#intermediary-manyt
> omany
>
> The Group object has through="Membership".
>
> Although, one thing I notice is that it looks like in the Django example
> it is only using 1 ManyToMany field (e.g. the Person model does not have a
> manytomany field). Is that required? Only one of the related items can
> have a ManyToMany declared?
>
> That wouldn't make a lot of sense though, right? I would want to ask for
> all Restaurants a Hood as....and vice versa. I'd want all of the Hoods
> that belong to a Restaurant.
>

You only place it on one side of the relationship. Django magic adds
the appropriate methods to the other side of the relationship. DRY -
Dont Repeat Yourself.

Cheers

Tom

--
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