Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#25911 closed Bug (needsinfo)

The decorator override_settings resets SETTINGS_MODULE variable

Reported by: Vitaliy Yelnik Owned by: nobody
Component: Testing framework Version: 1.9
Severity: Normal Keywords: override_settings
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

from django.conf import UserSettingsHolder, settings

# output 'service.settings.local'
print settings.SETTINGS_MODULE

# from code override_settings
override = UserSettingsHolder(settings._wrapped)

# output None
print override.SETTINGS_MODULE

# output 'service.settings.local'
print override.default_settings.SETTINGS_MODULE

Change History (7)

comment:1 Changed 5 years ago by Tim Graham

Could you elaborate on why this is a problem?

comment:2 Changed 5 years ago by Tim Graham

Resolution: needsinfo
Status: newclosed

comment:3 Changed 5 years ago by Vitaliy Yelnik

I have because of this began to fall tests, as this variable is used in a third-party module

comment:4 Changed 5 years ago by Tim Graham

I'm not sure, but it might be viewed as intentional/correct behavior since if you're overriding some settings, you're no longer using the original settings module. I'd be interested to see how the third-party module is using the variable.

comment:5 in reply to:  4 Changed 5 years ago by Vitaliy Yelnik

Replying to timgraham:

I'm not sure, but it might be viewed as intentional/correct behavior since if you're overriding some settings, you're no longer using the original settings module. I'd be interested to see how the third-party module is using the variable.

Coffin: Jinja2 extensions for Django
URLExtension class, line 205

comment:6 Changed 5 years ago by Tim Graham

I don't find that usage a compelling reason to fix this ticket as it's based on a common convention (but not a requirement) of the structure a Django project. Also, reversing URLs by dotted path is deprecated and removed in Django 1.10.

comment:7 Changed 5 years ago by Vitaliy Yelnik

Maybe it's worth it to add to the documentation?

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