So by using a combination of fields and exclude in the Meta class, I
can choose what fields I want for that form. Nice! :)
Two questions though:
1. Will fields be presented in the order specified in the fields
tuple?
2. In my original model/form diagram, will there be a way for me to
use the model's help_text as the field label?
Keith
On Aug 22, 4:24 pm, lingrlongr <[EMAIL PROTECTED]> wrote:
> Ah, so I guess ModelForm will work with the FormWizard? I'll have to
> look through that documentation. Reading documentation is easier than
> pulling my hair out! =)
>
> Thanks Rajesh.
>
> On Aug 22, 4:14 pm, Rajesh Dhawan <[EMAIL PROTECTED]> wrote:
>
> > Hi Keith,
>
> > > I'm using the form wizard for a project. All the field names in
> > > models.py coincide with the field names in forms.py. There is ONE
> > > field that is consistently, yet sporadically, causing problems and I
> > > cannot see why.
>
> > > # models.py
> > > class PurchaseApplication(BasicApplication):
> > > down_payment_assets = models.IntegerField(help_text=u'Available
> > > assets for down payment')
>
> > > # forms.py
> > > class PurchaseForm3_yes(forms.Form):
> > > down_payment_assets = forms.IntegerField(label=u'Available assets
> > > for down payment ($)')
>
> > > So, as I said, all the field names for the model and the form, so to
> > > save I use:
>
> > > class PurchaseWizard(FormWizard):
> > > def done(self, request, form_list):
> > > data = {}
> > > for f in form_list:
> > > data.update(f.cleaned_data)
>
> > > o = PurchaseApplication()
>
> > > for f in data:
> > > o.__setattr__(f, data[f])
> > > o.site = Site.objects.get_current()
> > > o.save()
>
> > > So, its only the down_payment_assets field that is causing problems,
> > > but only sporadically. The error text looks like this:
>
> > > Exception Type: OperationalError
> > > Exception Value: (1048, "Column 'down_payment_assets' cannot be
> > > null")
>
> > > But the request.POST vars in actally show a value!!
>
> > > Variable Value
> > > 1-credit_rating u'1'
> > > 2-purchase_home_type u'1'
> > > 2-down_payment_assets u'30000'
> > > <-----------------------------
> > > 0-best_time u'1'
> > > 1-contact_me u'N'
> > > wizard_step u'2'
>
> > > Thoughts?
>
> > Looks like o.__setattr__(f, data[f]) is not doing it's job for the
> > field down_payment_assets. You might want to print or log what's in
> > 'data' before you iterate over it.
>
> > Also, are you aware that Django's built-in ModelForm provides similar
> > functionality to what you seem to be trying to achieve above?
>
> >http://www.djangoproject.com/documentation/modelforms/
>
> > -Rajesh D
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---