On Tuesday, 29 January 2013 02:12:38 UTC-6, devver wrote: > > 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 > > > 1. class RegInfo(SessionWizardView): > 2. template_name = 'gest/wizard_form.html' > 3. file_storage = FileSystemStorage(location=os.path.join(settings. > MEDIA_ROOT, 'docs')) > 4. > 5. def get_context_data(self, form, **kwargs): > 6. context = super(RegInfo, self).get_context_data(form, > **kwargs) > 7. > 8. if self.steps.current == 'six': > 9. print 'step 6' > 10. > 11. return context > 12. > 13. def done(self, form_list, **kwargs): > 14. dati = self.get_all_cleaned_data() > 15. > 16. s = Info() > 17. s.tec = self.request.user > 18. s.dataso = dati['dataso'] > 19. > 20. s.docfile1 = ???????? > 21. > 22. s.save() > 23. > 24. return render_to_response('gest/done.html', { > 25. 'form_data': [form.cleaned_data for form in form_list], > 26. }) > 27. > 28. > > docfile1= self.request.FILES['<step for Step6 >-docfile1'] > s.docfile1 = docfile1 > Note that there is a prefix for the request.FILES key which is the 'step' name defined for the form.
-- 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+unsubscr...@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. For more options, visit https://groups.google.com/groups/opt_out.