I have moved along some more. Now Using this snippet (
http://www.djangosnippets.org/snippets/148/ )
z = FOO.objects.get(id=pram_id)
y = z.BAR.filter(off = False)
#.....
form_dict = {}
for x in y:
form_dict[x.id] = forms.BooleanField(required= False)
#....
form = DynForm()
form.setFields(form_dict)
That works great and creates a form with a ton of indivual checkbox
fields that I can refence like {{ form.## }} but it is still not what
I want.
I pass the form and y to the template. Now I have it set up like this.
{% for x in y_list %}
{{ x.other_info }}
{{ form.{{X.id}} }}
{%endfor %}
That doesnt work, it tries to parse the {{ and fails. I tried to
switch it to {{ form.x.id }} no luck on that. It seems to be looking
for a field named "x" not the object I am refencing.
The question now is how can you refence a variable in a template in
side another variable?
On Apr 21, 9:12 am, Raisins <[EMAIL PROTECTED]> wrote:
> I have it implemented without new forms for now. Anyone have an idea
> how I could do it with new forms?
>
> On Apr 18, 5:11 pm,Raisins<[EMAIL PROTECTED]> wrote:
>
> > I am trying to create a dymanic MultipleChoiceField with the
> > CheckboxSelectMultiple widget. The thing I want different, is the all
> > the list for the Choice field I want to be references to that object.
>
> > c = Model1.objects.get(id=temp_id)
> > i = [ ['-','-']]
> > for x in c.m2mModel2.all():
> > i.append([x,x])
> > dynamicForm.base_fields['dynamic_choice'].choices = i[1:]
> > #....
> > form = dynamicForm()
>
> > That works OK and creates the list and displays it with the list of
> > many to many with checkboxes. But they are all as one field.
> > What i though is to have each of the options be a reference to Model2
> > from the many 2 many fields. So i could display more info from
> > Model2.
> > The first solution I though of was {% for x in form.dynamic_choice %}
> > but it returns 'BoundField' object is not iterable.
>
> > Basically do a MultipleChoiceField with a m2m and each option be one
> > of those objects.
>
> > Any idea how I could?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---