Opened 16 years ago

Closed 16 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

Description

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 16 years ago.

Download all attachments as: .zip

Change History (3)

by Maxim Ivanov, 16 years ago

Attachment: dj.patch added

comment:1 by dc, 16 years ago

Needs tests: set

It can be done with

from django.views.default import page_not_found

def my_view(request, *args, **kwargs):
    try:
        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 by Maxim Ivanov, 16 years ago

Resolution: invalid
Status: newclosed

Agree.

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