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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:41:22+00:00 2026-05-17T20:41:22+00:00

In my development system (mac os x) I added the following lines at the

  • 0

In my development system (mac os x) I added the following lines at the end of my urls.py file:

if re.match('darwin',sys.platform):
# serving media files using the development server
    urlpatterns += patterns('',(r'^site_media/(?P<path>.*)$',
        'django.views.static.serve',
        {'document_root': '/Users/henri/sites_django/wmsproject/wmssite/site_media'}),)

in order to serve media files.

Everything goes as expected, well almost…

I included a Middleware class to intercept processing before my views are called. In this middleware I defined a process_view function. Things are not working as expected so I inserted an ‘assert False’ as the first line of this function, as follows:

def process_view(self, request, view_func, view_args, view_kwargs):
    assert False

When I enter this url in my browser:

http://localhost:8000/site_media/images/logo_wms_web.gif

I see, much to my astonishment, the following information the dump:

self         <wmssite.middleware.LanguageMiddleware.LanguageRedirect instance at 0x10117fe60>
view_args    {}
view_func    <function serve at 0x101281578>
view_kwargs  {'document_root': '/Users/henri/sites_django/wmsproject/wmssite/site_media', 'path': u'images/logo_wms_web.gif'}

The parameters I see in the dump are exactly the parameters you seen in the urls.py file I just showed.
URL dispatching happens before views are called (obviously) but I also thought that Middleware was called AFTER url dispatching and before calling views. But this looks like the Middleware is called before URL dispatching.

So it seems I got it wrong. Can somebody explain when exactly Middleware is called in relation to URL dispatching?

  • 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-17T20:41:22+00:00Added an answer on May 17, 2026 at 8:41 pm

    What in the traceback leads you to the conclusion that the middleware is being called before URL dispatching? On the contrary, it is clear that it is being called after that, and before calling the view, as it clearly has the name of the view it is being despatched to – serve, in other words django.views.static.serve as defined in your urls.py.

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

Sidebar

Related Questions

What is a good resource to get started with Windows file system driver development
One of the vagaries of my development system (Codegear C++Builder) is that some of
My development machine is a quad core system, but I just ran into (
How do you manage development and deployment of a n-tier system that's made up
We are discussing development of an improved management infrastructure for our distributed system. We
I'm using Visual Studio Team System 2008 at work to do web development. I've
I'm working on a large c++ system that is has been in development for
I've got to do some significant development in a large, old, spaghetti-ridden ASP system.
I would like to try some iPhone development but am not a Mac user.
Macports is the only packaging system I have checked out on the Mac and

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.