Thursday, March 3, 2011

Re: Form/view for ManyToMany relationship

On Thu, Mar 3, 2011 at 11:50 AM, werefr0g <werefr0g@yahoo.fr> wrote:
> Hello,
>
> Sorry if I misunderstand, but what is wrong about using a ModelForm on your
> Film bounded to the film instance?

When I tried that I kept running into this error:
"Cannot set values on a ManyToManyField which specifies an
intermediary model. Use foo.FilmRole's Manager instead."

... which led me down a different path but perhaps I should have
persevered more.

I have googled this error extensively and spent some time digging into
Django internals to figure out what is happening. Basically I can see
that if Django didn't auto-generate the relationship manager class
then it will throw this error.

Conceptually I totally get why that is (it has no way of knowing what
values to assign to the extra fields). What I don't get is how I'm
supposed to get around it. Lets say I wanted to put some code
somewhere to munge the missing fields to some default value. Where
would I put that code?

I can't relate to the error message at all. I read about manager
classes and how I can override query sets and so on. Sure that
totally makes sense. But how does that help me here? How can I use
the manager for FilmRole? Do I need to override some method in my
manager? Which method? An example would be really useful here.

Thanks.

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