KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm writing a Django Middleware class that I want to execute only once at startup, to initialise some other arbritary code. I've followed the very nice solution posted by sdolan here , but the "Hello" message is output to the terminal twice . E.g. from django.core.exceptions import MiddlewareNotUsed from django.conf import settings class StartupMiddleware(object): def __init__(self): print "Hello world" raise MiddlewareNotUsed('Startup complete') and in my Django settings file, I've got the class included in the MIDDLEWARE_CLASSES list. But when I run Django using runserver and request a page, I get in the terminal Django version 1.3, using settings 'config.server' Development server is running at http://127.0.0.1:8000/ Quit the server with CONTROL-C. Hello world [22/Jul/2011 15:54:36] "GET / HTTP/1.1" 200 698 Hello world [22/Jul/2011 15:54:36] "GET /static/css/base.css HTTP/1.1" 200 0 Any ideas why "Hello world" is printed twice? Thanks.
Tags (comma-separated)
Save Edits
Cancel