2π
β
I need to pass the data from the AddressForm to the model Address object to call the .save method (?)
Then you probably should be just using a model form
class AddressForm(forms.Form):
class Meta:
model = Address
You can then just call form.save()
and let django do the magic for you.
Either way, you should be calling is_valid
prior to trying to access any data. This exposes the formβs cleaned_data
dictionary which contains all the forms values post-validation.
π€Sayse
4π
The way you get any field value: by calling is_valid()
and then form.cleaned_data[fieldname]
.
π€Daniel Roseman
Source:stackexchange.com