django - Loading MultipleChoiceField initial values from session variables -
i'm trying pass list between 2 views , using session variables so.
def enrollmentverification(request): session_enrollments = enrollment.objects.filter(id__in=request.session["enrollments"]) if request.method == 'post': form = enrollmentverificationform(request.post) if form.is_valid(): # doing stuff else: form = enrollmentverificationform(initial={'enrollments': session_enrollments}) return render_to_response("cup/enrollment_verification.html", {'form': form, 's_enrollments': session_enrollments}, context_instance=requestcontext(request))
rendering s_enrollments
in list works in template, multiple selection widget empty. i've tried with:
form = enrollmentverificationform(initial={'enrollments': request.session["enrollments"]})
neither approach results in populated widget, if same data rendered list works fine. there's somewhere thinking twisted. ideas?
Comments
Post a Comment