Skip to content

Instantly share code, notes, and snippets.

@weex
Created September 11, 2021 21:56
Show Gist options
  • Save weex/2f185a0bc0ef4ad8190fd1e5bc7aa409 to your computer and use it in GitHub Desktop.
Save weex/2f185a0bc0ef4ad8190fd1e5bc7aa409 to your computer and use it in GitHub Desktop.
django shell error
$ django-admin shell
Python 3.9.2 (default, Feb 28 2021, 17:03:44)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.21.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: from thefederation.tasks import poll_nodes
---------------------------------------------------------------------------
ImproperlyConfigured Traceback (most recent call last)
<ipython-input-1-178073b1a85e> in <module>
----> 1 from thefederation.tasks import poll_nodes
~/code/the-federation.info/thefederation/tasks.py in <module>
12
13 from thefederation.enums import Relay
---> 14 from thefederation.models import Node, Platform, Protocol, Service, Stat
15
16 logger = logging.getLogger(__name__)
~/code/the-federation.info/thefederation/models/__init__.py in <module>
----> 1 from .node import *
2 from .platform import *
3 from .protocol import *
4 from .service import *
5 from .stat import *
~/code/the-federation.info/thefederation/models/node.py in <module>
10
11 from thefederation.enums import Relay
---> 12 from thefederation.models.base import ModelBase
13 from thefederation.utils import clean_hostname
14
~/code/the-federation.info/thefederation/models/base.py in <module>
4
5
----> 6 class ModelBase(models.Model):
7 uuid = models.UUIDField(unique=True, default=uuid.uuid4)
8 created = models.DateTimeField(auto_now_add=True)
~/.local/lib/python3.9/site-packages/django/db/models/base.py in __new__(cls, name, bases, attrs, **kwargs)
101
102 # Look for an application configuration to attach the model to.
--> 103 app_config = apps.get_containing_app_config(module)
104
105 if getattr(meta, 'app_label', None) is None:
~/.local/lib/python3.9/site-packages/django/apps/registry.py in get_containing_app_config(self, object_name)
250 Return None if the object isn't in any registered app config.
251 """
--> 252 self.check_apps_ready()
253 candidates = []
254 for app_config in self.app_configs.values():
~/.local/lib/python3.9/site-packages/django/apps/registry.py in check_apps_ready(self)
132 # INSTALLED_APPS raises a more helpful ImproperlyConfigured
133 # exception.
--> 134 settings.INSTALLED_APPS
135 raise AppRegistryNotReady("Apps aren't loaded yet.")
136
~/.local/lib/python3.9/site-packages/django/conf/__init__.py in __getattr__(self, name)
77 """Return the value of a setting and cache it in self.__dict__."""
78 if self._wrapped is empty:
---> 79 self._setup(name)
80 val = getattr(self._wrapped, name)
81 self.__dict__[name] = val
~/.local/lib/python3.9/site-packages/django/conf/__init__.py in _setup(self, name)
58 if not settings_module:
59 desc = ("setting %s" % name) if name else "settings"
---> 60 raise ImproperlyConfigured(
61 "Requested %s, but settings are not configured. "
62 "You must either define the environment variable %s "
ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment