```
from django.conf import settings as django_settings
isinstance(django_settings, type)
```
(via https://github.com/pytest-dev/pytest/issues/4266)
--
Ticket URL: <https://code.djangoproject.com/ticket/29906>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* resolution: => invalid
Comment:
As mentioned on the linked PR this has little to do with the `isinstance`
check; accessing `django.conf.settings` attributes (in this case
`__class__` through `isinstance`) is prohibited until
[https://docs.djangoproject.com/en/2.1/topics/settings/#calling-django-
setup-is-required-for-standalone-django-usage settings are configured].
--
Ticket URL: <https://code.djangoproject.com/ticket/29906#comment:1>
* type: Uncategorized => Bug
* component: Uncategorized => Core (Other)
Old description:
> Checking if `django.conf.settings` is a class should not trigger an
> exception, but the following code triggers ImproperlyConfigured already:
>
> ```
> from django.conf import settings as django_settings
> isinstance(django_settings, type)
> ```
>
> (via https://github.com/pytest-dev/pytest/issues/4266)
New description:
Checking if `django.conf.settings` is a class should not trigger an
exception, but the following code triggers ImproperlyConfigured already:
{{{
from django.conf import settings as django_settings
isinstance(django_settings, type)
}}}
(via https://github.com/pytest-dev/pytest/issues/4266)
--
--
Ticket URL: <https://code.djangoproject.com/ticket/29906#comment:2>
Comment (by Daniel Hahler):
Just for the record: it is not via ``__getattr__``, but because
``__class__`` itself is special property already:
https://github.com/django/django/blob/3d4d0a25b299a97314582156a0d63d939662d310/django/utils/functional.py#L305
I still think that ``isinstance()`` should not throw, but created a
fix/workaround for pytest nonetheless.
--
Ticket URL: <https://code.djangoproject.com/ticket/29906#comment:3>