Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8334447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:21:20+00:00 2026-06-09T03:21:20+00:00

views.py from textize.models import Textizer from django.http import HttpResponseRedirect from django.shortcuts import render_to_response from

  • 0

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)
        print "debug 0"  # <---It's not reaching this point when I submit the data via the form
        if form.is_valid():  #check to see if the input is valid
            print "debug 1"
            request.session['text'] = form.cleaned_data['to_textize']  #set the session key:value pair
            return HttpResponseRedirect('/results') #redirect to the results page

    else:
        form = Textizer()
        print "debug 2" # reaches here

    c = {'form': form}
    c.update(csrf(request))

    return render_to_response('index.html', c)

def results(request):
    text = request.session.get("text", "dummy")
    c = {'text' : text}
    return render_to_response('results.html', c)

index.html

<form action="/results" method="POST"> {% csrf_token %}
    {{ form.as_p }}
    <input type="submit" value="Submit" />
</form> 

results.html

<b>Input text: </b>{{ text }} 

I’m trying to pass data from the ‘index’ page to the ‘results’ page. In this case, I’d like to display the string typed and submitted on the results page.

What’s wrong with my form?

Also, am I forming the session key:value correctly?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T03:21:22+00:00Added an answer on June 9, 2026 at 3:21 am
    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):
    
        form = Textizer(request.POST or None)
    
        if request.method == 'POST':
            print "debug 0"
            if form.is_valid():
                print "debug 1"
                request.session['text'] = form.cleaned_data['to_textize']
    
        c = {'form': form, 'text':request.session.get("text", "")}
        c.update(csrf(request))
    
        return render_to_response('index.html', c)
    

    and then template index.html

    <form action="" method="POST"> {% csrf_token %}
        {{ form.as_p }}
        <input type="submit" value="Submit" />
    </form> 
    result: {{ text }}
    

    is enough to get this going.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I import models and views from Django Site1 to Site2 using the
here is my code: urls.py: from django.conf.urls import patterns from views import show,showpage urlpatterns
Django Endless Pagination works perfectly fine right until I use template inheritance. views.py: from
I am writing a GUI application using Django 1.1.1. This is the views.py: from
In django views,From the request how would we know from which page this view
I'm learning about using Custom Views from the following: http://developer.android.com/guide/topics/ui/custom-components.html#modifying The description says: Class
I have a django project that uses views from an external app. The view
In Django, is it not possible to have multiple views imports from the urls.py?
I want opinion and views from community. I am developing a large application with
We are investigating how to create data entry views from a dynamic list of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.