Saturday, 15 August 2015

python - How do I pass a list from one view to another in Django? -



python - How do I pass a list from one view to another in Django? -

i've been scouring stackoverflow, haven't found reply works me. relatively new python , django, maybe i'm thinking wrong.

to create simple example, imagine 2 views different associated urls. not supposed perfect code. i'm trying figure out how variable-length list of items view 1 view 2. don't see way via url because list may variably long. shouldn't extremely easy do?

def view2(request, list_to_process): utilize list_to_process manufacture formset (e.g. create formset 1 entry each item in list) homecoming render(request, 'project/template2.html', {'formset': formset}) def view1(request): if request.method == "post": if form.is_valid(): result = form.cleaned_data list_to_process = [] item in result: list_to_process.append(item) *what code utilize here phone call view2 , send list_to_process argument or request addition?* else: formset = formsettype() helper = assayhelper() (defined elsewhere) helper.add_input(submit("submit", "submit") homecoming render(request, 'project/template1.html', {'formset': formset, 'helper': helper})

can please help? thanks.

that session for. in view 1:

request.session['list'] = list_to_process

and in view 2:

list_to_process = request.session['list']

python django list django-views

No comments:

Post a Comment