Opened 5 years ago

Closed 5 years ago

#20019 closed Cleanup/optimization (fixed)

Set `HttpRequest.resolver_match` to `None` by default

Reported by: coolRR Owned by: nobody
Component: HTTP handling Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no


Sometimes my app has to deal with a request which does not have a .resolver_match object for some reason.

In these cases, I suggest that .resolver_match will have a value of None rather than not existing. This makes for much more elegant testing whether it exists or not.

Trivial patch attached.

Attachments (1)

patch.txt (464 bytes) - added by coolRR 5 years ago.

Download all attachments as: .zip

Change History (4)

Changed 5 years ago by coolRR

Attachment: patch.txt added

comment:1 Changed 5 years ago by coolRR

Component: UncategorizedHTTP handling
Type: UncategorizedCleanup/optimization
Version: 1.5master

comment:2 Changed 5 years ago by Aymeric Augustin

Easy pickings: set
Triage Stage: UnreviewedAccepted

Django generally creates in __init__ all attributes that may be set later on. I'll set the attribute at the instance level rather than at the class level. This is a small oversight in b946db5241b924c72c1079ce30d9b368e2b82f07.

comment:3 Changed 5 years ago by Aymeric Augustin <aymeric.augustin@…>

Resolution: fixed
Status: newclosed

In ce76fbfc5a14b0dbfdf28badb4bff874c8286d48:

Fixed #20019 -- Ensured HttpRequest.resolver_match always exists.

Obviously it isn't set until the URL is resolved.

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