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.
--
Ticket URL: <https://code.djangoproject.com/ticket/33162>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Old description:
> 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.
New description:
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.
--
--
Ticket URL: <https://code.djangoproject.com/ticket/33162#comment:1>
Old description:
> 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.
New description:
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.
--
--
Ticket URL: <https://code.djangoproject.com/ticket/33162#comment:2>
* status: new => closed
* resolution: => wontfix
Comment:
You can use `settings.SETTINGS_MODULE` to check the actual module and
`importlib` to get the file, e.g.
{{{
>>> from django.conf import settings
>>> import importlib
>>> importlib.import_module(settings.SETTINGS_MODULE).__file__
'/django/tests/test_pg.py'
}}}
I don't think that a hook is needed in Django itself.
--
Ticket URL: <https://code.djangoproject.com/ticket/33162#comment:3>