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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:28:28+00:00 2026-06-09T12:28:28+00:00

I am just building a simple HTML form with POST method and unfortunately I

  • 0

I am just building a simple HTML form with POST method and unfortunately I am finding CSRF verification error.

This is just a simple html form using POST method on localhost. There are no cross sites involved. I could definitely fix it by using csrf_token but I still don’t understand why django is asking me for that..

There are no re-directions/ iframes involved here…

So, why this is happening?? is this normal to all ??

# Also tried using RequestContext(request) but there isn't any change in the error

#settings.py 
'django.middleware.csrf.CsrfViewMiddleware' in MIDDLEWARE_CLASSES

#views.py 

# url for home page is "" i.e, http://127.0.0.1:8000/
def HomePage (request):
    if request.method == "POST":
        form = myForm(request.POST)
        if form.is_valid():
            data = form.cleaned_data
            context = { "myForm" : myForm(choices),
                        "values" : data,
                       }
            return render_to_response("home.html", context)
    else:
        form = myForm(choices)
    context = {"myForm" : form}
    return render_to_response("home.html", context)   


# home.html 

<div id="pingmeeForm">
            <form action="" method="post">
                <table>
                    {{myForm.as_table}}
                </table>
                <input name="enter" type="submit" value="enter"/>
            </form>
            {{values}}
</div>

# forms.py

class myForm (forms.Form):

    def __init__(self, my_choices,*args, **kwargs):
        super(myForm, self).__init__(*args, **kwargs)
        self.fields['Friends'] = forms.ChoiceField(choices=my_choices)

    message = forms.CharField()
  • 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-09T12:28:29+00:00Added an answer on June 9, 2026 at 12:28 pm

    If you do a post request, you typically change the state of the server. If you change the state of the server, you don’t want to allow other sites to do so. To protect against other sites issueing post-requests on your server, you add csrf protection. Therefore the solution should (imho) never be to remove the Csrf protection. Depending on the situation, either of the following two is the case:

    1. Your post request does not change the state. In that case, make it a get request.
    2. Your post request changes the state. You need CSRF.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If you are building a simple website using just simple HTML/CSS/Javascript that has say
I am building a simple user registration form using the MVC design pattern, in
I am fairly new to Flotr2 and I have just been building some simple
I am building simple notificiation system and I just wanted to know what is
I'm very new to MVC, and just building my first site, using NerdDinner as
Just getting started building an app using the v6 of the facebook c# sdk
I'm just getting into using REST and have started building my first app following
Need just a push in the right direction with this. I'm building a multi-language
This build warning just started showing up. I'm building for 3.1.3. Not sure what
I am using LINQ-to-XML. I am building a small program that helps parse HTML.

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.