Opened 6 years ago

Closed 6 years ago

Last modified 3 years ago

#9005 closed (fixed)

url templatetag incorrectly assumes settings.SETTINGS_MODULE is not set to None

Reported by: metzen Owned by: nobody
Component: Template system Version: master
Severity: Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

When rolling your own config using conf.settings.configure() instead of the DJANGO_SETTINGS_MODULE environment variable, settings.SETTINGS_MODULE gets set to None. Any code which assumes that settings.SETTINGS_MODULE has been set to a string would be incorrect.

I've attached a patch to fix an occurrence of this issue in the url templatetag which currently causes an AttributeError: 'NoneType' object has no attribute 'split'.

Attachments (2)

testfornone.diff (1.2 KB) - added by metzen 6 years ago.
9005-with-tests.diff (3.2 KB) - added by ericholscher 6 years ago.
Patch with tests. Fails on trunk with above-mentioned error, passed with patch with correct lack of url resolution.

Download all attachments as: .zip

Change History (9)

Changed 6 years ago by metzen

comment:1 Changed 6 years ago by anonymous

  • milestone post-1.0 deleted

Milestone post-1.0 deleted

comment:2 Changed 6 years ago by jacob

  • milestone set to 1.1
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:3 Changed 6 years ago by bthomas

  • Has patch set

comment:4 Changed 6 years ago by ericholscher

  • Needs tests set

This code needs to have a test associated with it so that this functionality doesn't happen again.

Changed 6 years ago by ericholscher

Patch with tests. Fails on trunk with above-mentioned error, passed with patch with correct lack of url resolution.

comment:5 Changed 6 years ago by Alex

  • Needs tests unset
  • Triage Stage changed from Accepted to Ready for checkin

comment:6 Changed 6 years ago by jacob

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

(In [10351]) [1.0.X] Fixed #9005: don't wig out when reversing a URL if SETTINGS_MODULE isn't set. While I was there, I fixed #10599 by re-raising the original error message, which is almost always a better idea. Thanks, Eric. Backport of r10350 from trunk.

comment:5 Changed 3 years ago by jacob

  • milestone 1.1 deleted

Milestone 1.1 deleted

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