A funny thing I’ve noticed about Django’s flatpages app: it allows core/handlers/base.py to log a warning Not Found: $page. As a result of that, my Sentry logs are full with 404s for legitimate and working pages. It seems to happen because first Django logs a 404, then it returns a HttpResponseNotFound object and then the flatpages middleware kicks in and returns a proper 200 response.
Is this something I could consider a bug in Django? My reasoning is that a valid flatpage is not a missing page and thus shouldn’t log a 404 message. Isn’t there an other way to catch a 404 without logging it as missing?
It’s not a bug, it’s the way that django flatpages app work: its middleware kicks in after 404 from urls. That’s why your sentry is full of 404s.
Consider not registering 404 in sentry. :/ I dont see any other way here.
There might be another solution: instead of using
middlewaretry to includeflatpages.urlsat end of your urlpatterns.