Closed brechmos closed 10 years ago
How do I set a model field after form submission? I have a model field that I am excluding from the form view and want to set it after the form is submitted based on a form field that was shown. I tried:
class PersonCreate(PersonCRUDView, CreateView): def form_valid(self, form): form.cleaned_data['ssn_last_four'] = form.cleaned_data['ssn'][-4:] return super(PersonCreate, self).form_valid(form)
but this isn't working. How do I do it?
Hiya,
I'd love to help but don't have the spare time to look into usage questions. The issue tracker is for bug reports and feature requests.
Sorry not to be more help.
How do I set a model field after form submission? I have a model field that I am excluding from the form view and want to set it after the form is submitted based on a form field that was shown. I tried:
class PersonCreate(PersonCRUDView, CreateView): def form_valid(self, form): form.cleaned_data['ssn_last_four'] = form.cleaned_data['ssn'][-4:] return super(PersonCreate, self).form_valid(form)
but this isn't working. How do I do it?