Opened 4 years ago

Closed 4 years ago

#17033 closed Bug (invalid)

Flatpage app urls redirect to 404 template if custom handler404 is set and DEBUG = False

Reported by: kamelok Owned by: nobody
Component: contrib.flatpages Version: 1.3
Severity: Normal Keywords: handler404
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

It appears only if DEBUG = False, any url that is not in urls.py (and Flatpage app urls are not) redirect to 404.
If DEBUG = True - Flatpage app work as expected.
If remove handler404 from urls - also Flatpages app work as expected.

core.views.py

def custom_404_view(request):
        return render_to_response("404.html", {'event': Event.objects.get(pk=1)}, context_instance=RequestContext(request))

def custom_500_view(request):
        return render_to_response("500.html", {}, context_instance=RequestContext(request))

urls.py

# Handlers for 404 and 500
handler404 = 'core.views.custom_404_view'
handler500 = 'core.views.custom_500_view'

Change History (1)

comment:1 Changed 4 years ago by claudep

  • Component changed from Uncategorized to contrib.flatpages
  • Keywords flatpages removed
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

My guess is that as your custom_404_view does not return a 404 HTTP code, the fallback middleware does not catch it. Please try to return a HttpResponseNotFound response and reopen if you can still reproduce it.

Note: See TracTickets for help on using tickets.
Back to Top