Very new to Django and am trying to create an application with several
form comprising a model class. I am using:
from django import newforms as forms # and not the ModelForm
The begining of my Policy model looks like:
class Policy(models.Model):
zip_code = models.CharField(maxlength=5)
current_insurance = models.CharField(maxlength=1, choices=YN_CHOICES)
license_more_than_3yrs = models.CharField(maxlength=1,
choices=YN_CHOICES)
acc_viol_3yrs = models.CharField(maxlength=1, choices=YN_CHOICES)
first_name = models.CharField(maxlength=20, null=True)
last_name = models.CharField(maxlength=25, null=True)
And my segment of my view is like:
form_zip_code = form.clean_data['zip_code']
form_current_insurance =
form.clean_data['current_insurance']
form_license_more_than_3yrs =
form.clean_data['license_more_than_3yrs']
form_acc_viol_3yrs = form.clean_data['acc_viol_3yrs']
p = Policy(zip_code=form_zip_code,
current_insurance=form_current_insurance,
license_more_than_3yrs=form_license_more_than_3yrs,
acc_viol_3yrs=form_acc_viol_3yrs)
p.save()
I was using the same namespace in my model/view/form and would have
prefered to do something like:
form_zip_code = form.clean_data['zip_code']
current_insurance = form.clean_data['current_insurance']
license_more_than_3yrs =
form.clean_data['license_more_than_3yrs']
acc_viol_3yrs = form.clean_data['acc_viol_3yrs']
p = Policy(zip_code, current_insurance,
license_more_than_3yrs,
acc_viol_3yrs)
p.save()
But this does not work. What can I do different? I would like move to
the ModelForm but there a few dependancies that I need to figure out
and I would like to get this to work cleanly before I do.
Thanks
Frank
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---