On 12/01/07, Honza Král <honza.k...@gmail.com> wrote:
Good, I'll stick with the subclassing. This seems to work well enough.
> > 2. Saving the model - I've implemented a save method in the form which
> > will return an instance of the model in a similar fashion to
> > form_for_model. Is this good practice or should I create the instance
> > in my view and populate it from the form?
> I do the same thing since I reuse the form in multiple views
This does seem to work, but not I'm getting into trouble when I bind
it to an instance.
> > 3. Binding data - I'd like the form to handle editing of an instance.
> > I could construct a dictionary of values and pass it to the form as
> > per the docs but I'd like to just pass a model instance and have the
> > form sort things out. Is this advisable? If so then does anyone have
> > any pointers about what methods I need to implement?
> the easiest way how to do this is in __init__ of the form create the
> dictionary from the model and use it when calling super.__init__
I've just implemented this but I run into trouble when I update the
model. At the moment I'm passing in the POST dict but things are
obviously going wrong as the form fails to validate but I don't get
Would it be possible for you to paste an example from one of your
form's __init__s? I have a feeling that I'm missing something obvious.
> > P.S. Are there any thoughts about form inheritance? I'd like to be
> > able to create a form base on another but with some more fields. At
> > the moment this doesn't seem to work as expected...
> it works but only for dynamic fields added via self.fields['name'] =
> I use it with success
I'll give this a go; thanks.