Opened 4 years ago
Closed 4 years ago
#33162 closed New feature (wontfix)
Add __file__ to Settings.
| Reported by: | Thomas Güttler | Owned by: | nobody |
|---|---|---|---|
| Component: | Core (Other) | Version: | 3.2 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description (last modified by )
Sometimes you have no clue which settings file is active.
For other files I use this pattern, to see which actual file is loaded:
assert 0, mylib.__file__
Unfortunately this does not work for django.conf.settings:
AttributeError: 'Settings' object has no attribute '__file__'
It would be super cool, if this attribute would be available.
Of course I could use:
assert 0, os.environ['DJANGO_SETTINGS_MODULE']
But sometimes the env var is not the actual file.
Change History (3)
comment:1 by , 4 years ago
| Description: | modified (diff) |
|---|
comment:2 by , 4 years ago
| Description: | modified (diff) |
|---|
comment:3 by , 4 years ago
| Resolution: | → wontfix |
|---|---|
| Status: | new → closed |
| Summary: | AttributeError: 'Settings' object has no attribute '__file__' → Add __file__ to Settings. |
Note:
See TracTickets
for help on using tickets.
You can use
settings.SETTINGS_MODULEto check the actual module andimportlibto get the file, e.g.I don't think that a hook is needed in Django itself.