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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:12:30+00:00 2026-05-26T10:12:30+00:00

I am trying to figure out this issue related to Django from https://github.com/miki725/Django-jQuery-File-Uploader-Integration-demo/issues/1 Under

  • 0

I am trying to figure out this issue related to Django from https://github.com/miki725/Django-jQuery-File-Uploader-Integration-demo/issues/1

Under what conditions can request.method == None in Django?

  • 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-26T10:12:31+00:00Added an answer on May 26, 2026 at 10:12 am

    TL;DR: request.method is never None in real use, but for your particular case, you’re looking at the wrong thing.

    Generic HttpRequest

    django/http/__init__.py:

    class HttpRequest(object):
        ...
        def __init__(self):
            ...
            self.method = None
            ...
    

    When a plain HttpRequest is instantiated, its method is None. But then, WSGIRequest and ModPythonRequest don’t call HttpRequest.__init__ ever.

    Requests through mod_wsgi

    django/core/handlers/wsgi.py:

    class WSGIRequest(http.HttpRequest):
        ...
        def __init__(self, environ):
            ...
            self.method = environ['REQUEST_METHOD'].upper()
            ...
    

    The summary of this is that for mod_wsgi, request.method will never be None. If in some warped way you managed to get environ['REQUEST_METHOD'] not being defined or being None, the request would fail.

    Requests through mod_python

    django/core/handlers/modpython.py:

    class ModPythonRequest(http.HttpRequest):
        ...
        def _get_method(self):
            return self.META['REQUEST_METHOD'].upper()
        ...
        method = property(_get_method)
    

    Same remarks as with WSGIRequest apply. Can’t ever be None.

    Test client

    django.test.client.RequestFactory.request instantiates a WSGIRequest and is called every time with REQUEST_METHOD defined in the environ as an uppercase string, as it should be.


    Summary:

    assert request.method is not None
    

    You’re looking for the error in the wrong place. In this case, request.method == 'POST'. It’s failing when request.META.get('CONTENT_TYPE', '') is None. The reason for this is that the Content-Type header isn’t being sent by the client in the request (don’t ask me why, I’m not familiar with that stuff).

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

Sidebar

Related Questions

after pulling my hair out for two days trying to figure this issue out
Im trying to figure out this HABTM relationship issue to store in the interests
I'm having a issue trying to figure out this. I need to fix some
This is a security issue I'm trying to figure out. Everything works fine and
Trying to figure out this pseudo code. The following is assumed.... I can only
In trying to figure out this problem (which is still unsolved and I still
I am trying to figure out this: c = 1 def f(n): print c
I'm trying to figure out how this would be done in practice, so as
I'm trying to figure out if this is normal. Because without errors, a connection
I'm trying to figure out why this works in FireFox, Chrome but not in

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.