[k] Replace excess try blocks with get_object_or_404

RESOLVED FIXED in 2.1

Status

support.mozilla.org
Knowledge Base Software
P3
normal
RESOLVED FIXED
8 years ago
8 years ago

People

(Reporter: jsocol, Assigned: jgross)

Tracking

unspecified

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [qa-][code quality][good first bug])

(Reporter)

Description

8 years ago
In forums.views there are a number of place we do basically this:

    try:
        obj = Cls.objects.get(x=y)
    except Cls.DoesNotExist:
        return Http404

That is just the long hand form of:

    from django.shortcuts import get_object_or_404

    obj = get_object_or_404(Cls, x=y)

For clarity and suscin...su....being concise, we should use the shortcut.
(Reporter)

Updated

8 years ago
Assignee: nobody → jgross
(Assignee)

Comment 1

8 years ago
http://github.com/jsocol/kitsune/commit/d4dadebe6786039a70d0ccec4b5ea1abf1da958c
Status: NEW → RESOLVED
Last Resolved: 8 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.