On Thu, Aug 2, 2012 at 7:06 AM, Gregory Thompson Jr. <spockthompso...@gmail.com> wrote: > I'd like to pass form data from one view to another. > > Here's my attempt: > > #Models.py > from django import forms > > class Textizer(forms.Form): > to_textize = forms.CharField(max_length=100) > > def __unicode__(self): > return self.to_textize > > #views.py > from textize.models import Textizer > from django.http import HttpResponseRedirect > from django.shortcuts import render_to_response > from django.core.context_processors import csrf > > def index(request): > if request.method == 'POST': > form = Textizer(request.POST) > > if form.is_valid(): > request.session['text'] = form.cleaned_data['to_textize'] > return HttpResponseRedirect('/results') > > else: > form = Textizer() > > c = {'form': form} > c.update(csrf(request)) > return render_to_response('C:/Documents and > Settings/quansai/projects/textsite/templates/index.html', c) > > def results(request): > text = request.session.get('text', None) > c = {'text' : text} > return render_to_response('C:/Documents and > Settings/quansai/projects/textsite/templates/results.html', c) > > > I really don't understand the following, and I've read the documentation > over and over. I've been on this for two days: > > How to initiate a session > How sessions are checked > How to retrieve form data from one page to handle the data on another.
In your template you can access the session variables as request.session.text. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.