Code

Opened 5 years ago

Closed 5 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 5 years ago.

Download all attachments as: .zip

Change History (3)

Changed 5 years ago by redbaron

comment:1 Changed 5 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 5 years ago by redbaron

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

Agree.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.