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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T02:34:51+00:00 2026-06-09T02:34:51+00:00

I get this error sometimes in custom Middleware in process_response method. I have the

  • 0

I get this error sometimes in custom Middleware in process_response method. I have the following list of middlewares:

MIDDLEWARE_CLASSES = [
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.doc.XViewMiddleware',
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'application.middleware.LastCampaignSessionMiddleware'

]

So session middleware is placed before my middleware. I don’t have any del request.session expressions in source code.
This is process_response method:

    def process_response(self, request, response):
        if 'last_campaign_id' in request.session and request.session['last_campaign_id']:
            if request.COOKIES['last_campaign_id'] != request.session['last_campaign_id']:
                response.set_cookie('last_campaign_id', request.session['last_campaign_id'])
        return response

Not sure why it could happen at all.

EDIT 03-08-2012 12-30

It looks like browser requesting favicon:

[03/Aug/2012 10:26:42] "GET /favicon.ico/ HTTP/1.1" 404 6701

Is there no default behavior in django to resolve this url? Because I didn’t explicitly specify view which should handle this request. And I don’t use favicon in page source code. So I guess it’s browser who requests /favicon.ico. I guess in case of 404 error HttpRequest wouldn’t construct properly so no wonder I have no session in request object. But it’s just my assumptions.

Also if it necessary I am using django dev server while getting this error.

EDIT 13-00

I have fixed this problem with favicon but still getting error. Why session may not exist in request?

  • 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-09T02:34:53+00:00Added an answer on June 9, 2026 at 2:34 am

    The problem was in middlewares order.

    CommonMiddleware returns HttpResponsePermanentRedirect in cases when to request url have been added ‘www’ or trailing ‘/’ (APPEND_SLASH and PREPEND_WWW in settings). In such case django stops looking through middleware list for process_request methods and begins to run process_response methods.

    It’s bad there is no information about such behavior for standard django middlewares (i.e. middleware could return in some cases HttpResponse object).

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

Sidebar

Related Questions

Sometimes users mistakenly redirected to ?Process=ViewImages&PAGEID=. When this happens, they get the following error.
I get this error sometimes reported when creating a dialog, i haven't experienced the
I get this error when I run the code below. I have normally used
I get this error when I use simplejson from django.utils in google app engine
When I transfer a file about 50Mb over HTTP sometimes I get this error:
I get this error randomly, sometimes it shows and sometimes not! The Error: Now
Sometimes in execution I get this error message in VS2010 when trying to free
I get this error sometimes, Catchable fatal error: Object of class stdClass could not
Sometimes I get this error message from time-based trigger of many scripts ... There
Sometimes I get this error when extracting youtube videos by json, here's an example:

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.