Thanks for your help -- I had tried both of those but couldn't get them
to work with generic views. In the end I just abandoned the generic
view and used the __init__() approach and things worked.
-- Casey
On 07/28/2010 09:35 AM, derek wrote:
> 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
>
> And another one:
> http://code-blasphemies.blogspot.com/2009/04/dynamically-created-modelmultiplechoice.html
>
--
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