Opened 6 years ago

Closed 6 years ago

#10987 closed (invalid)

[patch] generic object_detail support for custom 404 page

Reported by: redbaron 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: UI/UX:

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 redbaron 6 years ago.

Download all attachments as: .zip

Change History (3)

Changed 6 years ago by redbaron

comment:1 Changed 6 years ago by dc

  • Needs documentation unset
  • Needs tests set
  • Patch needs improvement unset

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 Changed 6 years ago by redbaron

  • Resolution set to invalid
  • Status changed from new to closed

Agree.

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