Skip to content

Instantly share code, notes, and snippets.

@nwjlyons
Last active September 14, 2016 10:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nwjlyons/7487f9943311f038cd4a459e03faba4b to your computer and use it in GitHub Desktop.
Save nwjlyons/7487f9943311f038cd4a459e03faba4b to your computer and use it in GitHub Desktop.
Don't log if path starts with /static/
from django.core.servers.basehttp import WSGIRequestHandler
# Grab the original log_message method.
_log_message = WSGIRequestHandler.log_message
def log_message(self, *args):
# Don't log if path starts with /static/
if self.path.startswith("/static/"):
return
else:
return _log_message(self, *args)
# Replace log_message with our custom one.
WSGIRequestHandler.log_message = log_message
# Import the original runserver management command
from django.core.management.commands.runserver import Command
@nwjlyons
Copy link
Author

nwjlyons commented Sep 14, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment