I created a form wizard of 6 steps,
in step sixth, have filefield for uploading docfile1
django docs is poor on this topic, google does not help.
my code working ok, but how handle filefield.
need example, thanks
forms.py
class Step6(forms.Form):
docfile1 = forms.FileField(required=False)
view.py
- class RegInfo(SessionWizardView):
- template_name = 'gest/wizard_form.html'
- file_storage = FileSystemStorage(location=os.path.join(settings.MEDIA_ROOT, 'docs'))
- def get_context_data(self, form, **kwargs):
- context = super(RegInfo, self).get_context_data(form, **kwargs)
- if self.steps.current == 'six':
- print 'step 6'
- return context
- def done(self, form_list, **kwargs):
- dati = self.get_all_cleaned_data()
- s = Info()
- s.tec = self.request.user
- s.dataso = dati['dataso']
- s.docfile1 = ????????
- s.save()
- return render_to_response('gest/done.html', {
- 'form_data': [form.cleaned_data for form in form_list],
- })
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment