> I've posted a code snippet that I think addresses your
> issue:http://www.djangosnippets.org/snippets/82/
>
Jeff, this was very helpful and I've moved on a bit, I can make your
form do exactly what it's supposed to. Howver I'm still struggling to
pass my information to the Form class.

I note that you've defined the size of your dictionary using in the
Form class using:
     number_of_meds = kwargs.pop('number_of_meds', 4)

How does this work? is it the only way I can tell the form class the
number if items in the dictionary?

Because my output is based on a query set, I'm going to have to put
this into a dictionary to pass to the form class, otherwise the field
names won't match with those in the class. So I cycle through my
queryset in the view and give each entry the appropriate field index
so it matches...

        data_list=UserPoints.objects.filter(user = myuser)
        for i in data_list:
            k='type_%d' % i
            l='points_%d' % i
 
data_dict[i]={k:data_list[i].points_type,l:data_list[i].total_points}

m=MyForm(data_dict)
context = Context({'form':m})
return render_to_response('template.html', context)

As you will see this doesn't work because I can't index the
dictionary.

Please can you advise:
The best way to pass my queryset data to the Form class
How to pass the number of records to the Form class

This might be pretty basic stuff, but I'm new to Python and Django and
it's causing me some grief.

Any advice wlecome.


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to