from views.py
def done(self, form_list, **kwargs):
user = self.request.user
resumes = form_list[0]
resumes.user = user
resumes.save()
return HttpResponseRedirect(reverse('resumes:my-resumes'))
from forms.py
class ResumeForm(ModelForm):
class Meta:
model = Resume
fields = ['name', ]
from models.py
class Resume(models.Model):
name = models.CharField(max_length=255)
created_at = models.DateTimeField(auto_now_add=True, editable=False)
updated_at = models.DateTimeField(auto_now=True)
user = models.ForeignKey(User, on_delete=models.CASCADE)
def __str__(self):
return self.name
Hi, I'm trying to configure the done method in my Wizard view (extends SessionWizardView). I want to access the first form in the form_list but this throws an error? What am I doing wrong?
I'm trying to insert user into a modelform before saving it (resume requires a user foreign key). I will also need to insert resume foreign key in other steps of the wizard form.
Any help would be much appreciated. Thanks!
There is method for that: get_form_step_data
and you must pass name of the step form.