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 8448733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:30:31+00:00 2026-06-10T10:30:31+00:00

I am new to django and have made a method:GET form with checkboxes/text boxes

  • 0

I am new to django and have made a method:GET form with checkboxes/text boxes and a submit button. I want to change it to a method:POST form but keep getting the error that says:

Reason given for failure:

CSRF token missing or incorrect.

In general, this can occur when there is a genuine Cross Site Request Forgery, or when Django’s CSRF mechanism has not been used correctly. For POST forms, you need to ensure:

Your browser is accepting cookies.

The view function uses RequestContext for the template, instead of Context.

In the template, there is a {% csrf_token %} template tag inside each POST form that targets an internal URL.

If you are not using CsrfViewMiddleware, then you must use csrf_protect on any views that use the csrf_token template tag, as well as those that accept the POST data.

I tried to change all the things that the debuger says to but I keep getting the same error. I would like to know if there are any other files that I need to change other than views.py, the template file(.html) and the settings.py file which are included here:

views.py:

from django.template import RequestContext, loader
from crunchApp.models import Filter
from django.http import HttpResponse
from django.core.context_processors import csrf
from django.shortcuts import render_to_response, get_object_or_404
from django.http import Http404    

def results(request):

    c = {}
    c.update(csrf(request))
    return render_to_response('crunchApp/results.html', c)

template/test.html

    <form name="myform" action="results" method = "post" >{% csrf_token %}
        <fieldset>
            <input type="checkbox" value="total_money" id = "money_check" name="check" /> Filter by Total Money</br>
    </fieldset></form>

settings.py

MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
)
  • 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-10T10:30:33+00:00Added an answer on June 10, 2026 at 10:30 am

    You shouldn’t need

    c = {}
    c.update(csrf(request))
    

    but you do need context_instance=RequestContext(request), as in

    render_to_response(<template>, <vars>, context_instance=RequestContext(request))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to make something like http://www.djangosnippets.org/accounts/register/ using django..the register form. I am new
I'm new to Django so I just made up an project to get to
I'm new to Django and I have a page with several forms and submit
I'm fairly new to Django and have a basic question: I want to use
I have a form on my Django site (made with ModelForm) where users can
I have a general question about the new Django 1.3 static file framework. I
I am rather new to django templates and have an impression that I have
I'm new to Django but I seem to have nearly identical code working on
I'm new with Django and python. I have a problem. Is there a way,
I'm new to Django, but the application that I have in mind might end

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.