From 171df93170df23d2fea1f8320ddb80c6f6444ff7 Mon Sep 17 00:00:00 2001 From: Luke Plant Date: Thu, 5 May 2011 20:49:26 +0000 Subject: Fixed #15954 - New IGNORABLE_404_URLS setting that allows more powerful filtering of 404s to ignore Thanks to aaugustin for implementing this. (Technically this doesn't fix the original report, as we've decided against having *any* default values, but the new feature makes it possible, and the docs have an example addressing #15954). git-svn-id: http://code.djangoproject.com/svn/django/trunk@16160 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- docs/howto/error-reporting.txt | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'docs/howto') diff --git a/docs/howto/error-reporting.txt b/docs/howto/error-reporting.txt index 063f943894..ddef93873e 100644 --- a/docs/howto/error-reporting.txt +++ b/docs/howto/error-reporting.txt @@ -66,15 +66,29 @@ a referer. (It doesn't bother to email for 404s that don't have a referer -- those are usually just people typing in broken URLs or broken Web 'bots). You can tell Django to stop reporting particular 404s by tweaking the -:setting:`IGNORABLE_404_ENDS` and :setting:`IGNORABLE_404_STARTS` settings. Both -should be a tuple of strings. For example:: +:setting:`IGNORABLE_404_URLS` setting. It should be a tuple of compiled +regular expression objects. For example:: - IGNORABLE_404_ENDS = ('.php', '.cgi') - IGNORABLE_404_STARTS = ('/phpmyadmin/',) + import re + IGNORABLE_404_URLS = ( + re.compile(r'\.(php|cgi)$'), + re.compile(r'^/phpmyadmin/'), + ) In this example, a 404 to any URL ending with ``.php`` or ``.cgi`` will *not* be reported. Neither will any URL starting with ``/phpmyadmin/``. +The following example shows how to exclude some conventional URLs that browsers and +crawlers often request:: + + import re + IGNORABLE_404_URLS = ( + re.compile(r'^/apple-touch-icon.*\.png$'), + re.compile(r'^/favicon.ico$), + re.compile(r'^/robots.txt$), + ) + + The best way to disable this behavior is to set :setting:`SEND_BROKEN_LINK_EMAILS` to ``False``. @@ -93,3 +107,10 @@ The best way to disable this behavior is to set records are ignored, but you can use them for error reporting by writing a handler and :doc:`configuring logging ` appropriately. +.. seealso:: + + .. versionchanged:: 1.4 + + Previously, two settings were used to control which URLs not to report: + :setting:`IGNORABLE_404_STARTS` and :setting:`IGNORABLE_404_ENDS`. They + were replaced by :setting:`IGNORABLE_404_URLS`. -- cgit v1.3