Re: Newforms - Dynamic Fields from a queryset

2007-03-16 Thread Tipan
> > >> number_of_meds = kwargs.pop('number_of_meds', 4) > > This is how I optionally passed the number of > fields I wanted to display in the form. If there's > no 'number_of_meds' in kwargs, a minimum of 4 fields > are displayed. The trick is to use kwargs.pop() before > super is called, or you

Re: Newforms - Dynamic Fields from a queryset

2007-03-15 Thread Rubic
On Mar 15, 12:30 pm, "Tipan" <[EMAIL PROTECTED]> wrote: > Realised my daft error in creating the dictionary. I've resolved that > now and can happily pass the queryset data to the Form class by > creating the dict. However, I'm still not sure how to pass the number > of records to the Form class.

Re: Newforms - Dynamic Fields from a queryset

2007-03-15 Thread Rubic
[reference: http://www.djangosnippets.org/snippets/82 ] Tipan, >From your code I think you may be confusing a dictionary key with a list index. > data_list=UserPoints.objects.filter(user = myuser) > for i in data_list: > k='type_%d' % i > l='points_%d' % i Note in line #28 how I'm defi

Re: Newforms - Dynamic Fields from a queryset

2007-03-15 Thread Tipan
Realised my daft error in creating the dictionary. I've resolved that now and can happily pass the queryset data to the Form class by creating the dict. However, I'm still not sure how to pass the number of records to the Form class. Can you advise? Tim --~--~-~--~~~--

Re: Newforms - Dynamic Fields from a queryset

2007-03-15 Thread Tipan
> 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 t

Re: Newforms - Dynamic Fields from a queryset

2007-03-14 Thread Rubic
Tipan, I've posted a code snippet that I think addresses your issue: http://www.djangosnippets.org/snippets/82/ -- Jeff Bauer Rubicon, Inc. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To

Newforms - Dynamic Fields from a queryset

2007-03-14 Thread Tipan
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