On Jul 26, 6:52 pm, "Casey S. Greene" <csgre...@princeton.edu> wrote: > Does anyone have a hint for this (or an idea of where to get started in > the documentation)? This seems relatively simple so my best guess is > that there is something that I am just missing. > > Thanks! > -- Casey > > On 07/22/2010 10:16 AM, Casey S. Greene wrote: > > > I am trying to figure out a reasonable way to filter using a queryset > > within a ModelForm. > > > In a simple example, I have three models (A, B, and C). > > C has many A and B > > A and B have a many to many relationship. > > > Assume that some instances of C and instances of B already exist. > > > I am using the create_object generic view to allow users to create > > instances of A but not to select associated Bs. I'm then using > > update_object generic view to allow users to select the Bs associated > > with A. I've created a class that inherits from forms.ModelForm that > > defines the form. In that I have forms.ModelMultipleChoiceField() for > > selecting associated Bs. What I want to do is use the queryset to filter > > to only show those Bs that share C with this instance of A. > > > I am confused as to how to do this type of query while passing a > > form_class from the update_object generic view. > > > I have tried doing this in __init__() but I get a TypeError that the > > form is not callable when I try to pass arguments. > > > Thanks in advance for your help and time, > > -- Casey
Well, I have never worked with "object generic view" items before, but a similar (I think?) question was raised on stackoverflow: http://stackoverflow.com/questions/738301/how-to-modify-choices-of-modelmultiplechoicefield Maybe the discussion (and links) there can help as a starting point? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.