Задать вопрос
@tried7373

Model class builtins.Topic doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS?

Что вызывает данную ошибку ?
Model class builtins.Topic doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS ?

Запускается файл (models.py) вот его код:
from django.db import models
class Topic(models.Model):
    """Тема, которую изучает пользователь."""
    text = models.CharField(max_length=200)
    date_added = models.DateTimeField(
        auto_now_add=True)
 
 def __str__(self):
     return self.text


А вот код файла(settings.py) :
INSTALLED_APPS = [
    # Мои приложения.
    'learning_logs',
    # Дефолтные приложения Django.
    'django.contrib.admin',
]


А при запуске из cmd появляется такая ошибка:
Traceback (most recent call last):
  File "D:\learning_log\learning_logs\models.py", line 7, in <module>
    class Topic(models.Model):
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\django\db\models\base.py", line 127, in __new__
    app_config = apps.get_containing_app_config(module)
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\django\apps\registry.py", line 260, in get_containing_app_config
    self.check_apps_ready()
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\django\apps\registry.py", line 137, in check_apps_ready
    settings.INSTALLED_APPS
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\django\conf\__init__.py", line 87, in __getattr__
    self._setup(name)
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\django\conf\__init__.py", line 67, in _setup
    raise ImproperlyConfigured(
django.core.exceptions.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.
</code
  • Вопрос задан
  • 854 просмотра
Подписаться 1 Простой 1 комментарий
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы