Opened 10 years ago

Closed 10 years ago

#10987 closed (invalid)

[patch] generic object_detail support for custom 404 page

Reported by: Maxim Ivanov Owned by: nobody
Component: Generic views Version: 1.1-beta
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: no UI/UX: no


It's handy to have custom 404 page for generic object_detail view. Such as "Sorry man, post not found". Here is a simple patch which adds handler404 keyword arg which should point to django template file.

Attachments (1)

dj.patch (2.6 KB) - added by Maxim Ivanov 10 years ago.

Download all attachments as: .zip

Change History (3)

Changed 10 years ago by Maxim Ivanov

Attachment: dj.patch added

comment:1 Changed 10 years ago by dc

Needs tests: set

It can be done with

from django.views.default import page_not_found

def my_view(request, *args, **kwargs):
        return object_detail(request, *args, **kwargs)
    except Http404:
        return page_not_found(request, template_name='my_404.html')

for e.g.

Which is less implicit and more versatile way.

comment:2 Changed 10 years ago by Maxim Ivanov

Resolution: invalid
Status: newclosed


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