Populating a ManyToMany field

2010-03-09 Thread Laereom
I have a model, Response, which has a ManyToMany field with the model Question named 'questionid'. When I create an instance of response like this: response = Response(questionid=question, blah, blah ) I receive the following error: TypeError at /answer 'questionid' is an invalid keyword argument

Re: Populating a ManyToMany field

2010-03-09 Thread Laereom
Awesome, thanks. I have been using The Django Book as my sole documentation, which was quite foolish of me. That gave me exactly what I needed -- sorry for not remembering to check the actual docs first! On Mar 9, 8:19 am, Daniel Roseman wrote: > On Mar 9, 4:15 pm, Laereom wr

Filtering by another object's ManyToMany properties

2010-03-10 Thread Laereom
I have two models, we'll call them 'Question' and 'Search'. Search has a many to many field called 'questions' which contain, naturally, a set of questions. I want to retrieve a Question which is associated with a particular Search through that many to many field. It seemed straightforward -- I

Re: Filtering by another object's ManyToMany properties

2010-03-10 Thread Laereom
Hey, thanks. EXACTLY what I needed. On Mar 10, 3:03 pm, Daniel Roseman wrote: > On Mar 10, 10:38 pm, Laereom wrote: > > > > > > > I have two models, we'll call them 'Question' and 'Search'. > > > Search has a many to many field

Dynamic forms through a class factory; 'string index out of range'

2010-04-10 Thread Laereom
As the title suggests, I'm creating a dynamic form via a class factory. Here is what I'm doing inside the class factory itself (as far as actually making the class goes): class _QuestionAnswerForm(forms.Form): response = forms.IntegerField(widget=RadioSelect

Re: Dynamic forms through a class factory; 'string index out of range'

2010-04-10 Thread Laereom
Honestly, I really don't like that method, mostly due to ugliness. I'm looking for a solution specifically to instantiating a form created via a class factory, unless that is some sort of Herculean task. On Apr 10, 10:13 am, Daniel Roseman wrote: > On Apr 10, 4:40 pm, L

Re: Dynamic forms through a class factory; 'string index out of range'

2010-04-10 Thread Laereom
Scratch that. I ended up doing it the other way. I went back and reviewed and it seemed less ugly now than it did at midnight last night. Funny, that. Thanks for the advice. On Apr 10, 10:45 am, Laereom wrote: > Honestly, I really don't like that method, mostly due to ugliness. >

Retrieving values of checked boxes as a csv string

2010-04-11 Thread Laereom
I have a form which contains checkboxes exclusively. Each checkbox has a distinct value. I want a csv string of the values of the boxes which are checked. First, I thought I'd retrieve a list of the fields with something that looked like this: for fields in form: if field.attrs['checked']=='