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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:05:51+00:00 2026-05-22T16:05:51+00:00

Coding in Django, using forms. I’m having a problem where if the form is

  • 0

Coding in Django, using forms. I’m having a problem where if the form is GET, then every field always shows up with an error “This field is required.”, but the problem doesn’t exist if the form is POST. Here’s a simple example (partial code),

views.py:

def login(request):        
    if request.method == 'GET':
        form = RegisterForm (request.GET)
    else:
        form = RegisterForm ()
return render_to_response('register.html', locals(), context_instance=RequestContext(request))

register.html:

<form action = "" method = "GET">
    <table style = "border: none;">
        <tr>
            <td class = "login"><strong>email:</strong></td>
            <td class = "login">{{ form.email }}</td>
            <td><span class = "error">{{ form.errors.email }}</span></td>
        </tr>

        ...
    </table>
</form>

If you change all the ‘GET’ to ‘POST’ everything’s fine. Or else the ‘form.errors.email’ will always throw a “This field is required.” error.

Another odd thing… doesn’t seem like I see any form objects being initiated with request.GET. The Django Book 2.0 only shows the form object initiated with request.POST. Is there something I’m missing here?

Many thanks for any tips.

EDIT: thanks for the tips from Craig and Ignacio. However, my question is that regardless of what I’m doing with this form, either GET or POST, having GET in the form always gives me form errors about “field required”. That’s the mechanic I’m not understanding. Any help on that would be greatly appreciated, thanks.

  • 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-05-22T16:05:52+00:00Added an answer on May 22, 2026 at 4:05 pm

    If I’m not mistaken, the default HTTP request method is always GET unless it is specified as POST. So when you access that view (using GET by default), you are already satisfying the if request.method == 'GET': statement, so it is automatically bringing up the validation error for inserting an empty data into the field. You never actually get to the else: form = RegisterForm() lines

    Check out django-debug-toolbar which is a very helpful toolbar and it allows you to see you request type and requet variables.

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

Sidebar

Related Questions

I'm willing to build a restful service using Django, I'm coming form RoR background
I'm using python, django and google app engine and I'm getting the error below.
basic problem: i need to create real customized templates for my django forms. That's
I've been drooling over Django all day while coding up an internal website in
Coding footer naively, if there's not enough content, then there will be empty space
from django.utils.simplejson import dumps, loads # -*- coding: utf-8 -*- def index(request): return render_to_response('test2/index.html')
I am using the latest checkout of the django trunk - when I am
I have the following code, using Django ORM routes =Routes.objects.filter(scheduleid=schedule.id).only('externalid') t_list = [(route.externalid, route.vehicle.name)
Greetings I want to slugify/normalize utf8 string however I get # -*- coding: utf-8
I'm having problems using {% ifequal s1 some text %} to compare strings with

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.