I wonder if anyone can give me some pointers. I've been working with new forms with reasonable results, but I've come across a problem when creating a form with dynamic fields and rendering to an HTML template.
I want to create a form using data from a queryset which extracts data for a specific user. Alongside each row, I want to place a checkbox which the user can tick to indicate their preference. The output table would look something like this: <table border=1> <tr><td> Points Type </td><td >Points</td><td> Select</td></tr> <tr><td> Points Type 1</td><td >Points</td><td> Select</td></tr> <tr><td> Points Type 2</td><td >Points</td><td> Select</td></tr> <tr><td> Points Type n</td><td >Points</td><td> Select</td></tr> The intention here being that the user can select one or more rows and use them in further processing. I've defined the form class as: class MyForm(forms.Form): def __init__(self, *args, **kwargs): super(MyForm, self).__init__(*args, **kwargs) qs=UserPoints.objects.all() for i in qs: self.fields['type_%s' % i.type_id] = forms.CharField() self.fields['points_%s' % i.points] = forms.CharField() self.fields['select_%s % i]=forms.BooleanField() In my view I call the form and return the response to the template. myuser=request.user if request.method == "POST": form=MyForm(request.POST) if form.is_valid(): etc.... else: form=MyForm() context = Context({'form':form) return render_to_response('mytemplate.html', context) My issue is that I want to be able to filter the form queryset so that it only shows the specific user's records - can anyone suggest a way to do this. I also want to output the various fields on the form in the HTML template, but I can't work out the correct syntax. I'm probably doing something daft through lack of experience. However, any insight gretaly received. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---