Re: Customizing the class returned by newforms.form_for_model()

2007-03-03 Thread Kai Kuehne
Hi Honza, On 1/16/07, Honza Král <[EMAIL PROTECTED]> wrote: > the same way the class itself is constructed: > type(name, parent_list, { __dict__} ) I've liked python, but now I'm loving it. Thank you for the eye-opener. :-) Kai --~--~-~--~~~---~--~~ You received

Re: Customizing the class returned by newforms.form_for_model()

2007-03-02 Thread brooks
One option would be to simply re-assign the value for that field in the form instance/class base_fields, ala: Model_Form = forms.models.form_for_model(Model) Model_Form.base_fields['multi_field'] = forms.CharField(maxlength=150, initial=Model_Form.base_fields['multi_field'].initial) Hope that he

Re: Customizing the class returned by newforms.form_for_model()

2007-01-15 Thread jfagnani
So subclassing the generated form class does work, just type something like: class MyForm(forms.form_for_model(MyModel)): my_field = forms.CharField() ... (Python is very interesting :) But there's a not-so-small catch: new fields defined in the subclass don't get added to the fields diction

Re: Customizing the class returned by newforms.form_for_model()

2007-01-15 Thread Honza Král
plus you can supply a super class that the resulting class will subclass via the form keyword argument... On 1/16/07, Honza Kr l <[EMAIL PROTECTED]> wrote: On 1/16/07, jfagnani <[EMAIL PROTECTED]> wrote: > > I'm just starting to learn newforms myself, but it looks like > form_for_model returns a

Re: Customizing the class returned by newforms.form_for_model()

2007-01-15 Thread Honza Král
On 1/16/07, jfagnani <[EMAIL PROTECTED]> wrote: I'm just starting to learn newforms myself, but it looks like form_for_model returns a class, so shouldn't you be able to subclass it? I'm not sure how that would work though, since the class doesn't exist when defining your subclass, but that's b

Re: Customizing the class returned by newforms.form_for_model()

2007-01-15 Thread jfagnani
I'm just starting to learn newforms myself, but it looks like form_for_model returns a class, so shouldn't you be able to subclass it? I'm not sure how that would work though, since the class doesn't exist when defining your subclass, but that's because I'm new to Python too :) --~--~-

Customizing the class returned by newforms.form_for_model()

2007-01-15 Thread [EMAIL PROTECTED]
Hello everyone, I am looking for a way to modify certain aspects of a Form class returned by newforms.form_for_model(). I have a ManyToManyField(Tag) attribute in my model and form_for_model() makes that a multiple select. I was wondering if it was possible to change just that field to a CharF