I currently have a SessionWizardView from formtools package implemented.
class DataframeFormView(SessionWizardView):
def done(self,form_list):
params={}
for form in form_list:
params.update(form.cleaned_data)
return HttpResponseRedirect(reverse('download',kwargs={'params':params}))
Everything is working fine in the forms view, and when the forms are successfully filled the above mentioned function runs, however I need to pass the params argument to another view:
from django_downloadview import VirtualDownloadView, VirtualFile
class DataframeDownloadView(VirtualDownloadView):
def get_file(self):
### Access params dictionary here!!!!
return VirtualFile(tfile.name, name=tfile.name)
Thing I've tried:
1) override __init__
to add self.params = kwargs.pop('params')
2) create method to access to kwargs specific key params using return self.kwargs['params']
3) Mixin solution (probably badly implemented but I thing there are constraints in these two CBVs)
Ultimately, suing method 1 and 2, I manage to access merely to a string representation of the params dictionary through reversing to download/url/. I need a more programatically solution to obtain the original dict object. TLDR: How can I pass complex objects between views.
Best regards,
As suggested by kungphu, probably the best way to share complex objects between views is using the view session. For future reference, I end up doing the following:
and I also changed the session serializer to pickle.