Вот часть кода settings
INSTALLED_APPS = [
'articles.apps.ArticleConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
Вот код models
from django.db import models
class Article(models.Model):
article_title = models.CharField('Название статьи', max_length = 200)
article_text = models.TextField('Текст статьи')
pub_date = models.DateTimeField('Дата публикации')
class Comment(models.Model):
article = models.ForeignKey(Article, on_delete = models.CASCADE)
author_name = models.CharField('Имя автора', max_length = 100)
comment_text = models.CharF
Вот код apps
from django.apps import AppConfig
class ArticlesConfig(AppConfig):
name = 'articles'
Я переходил на связанные темы, но именно общего с этой проблемы не нашел. Я добавил в settings приложение.
D:\Django\myfirst>python manage.py makemigrations articles
Traceback (most recent call last):
File "C:\Users\Таирлан\AppData\Local\Programs\Python\Python38-32\lib\site-pack
ages\django\apps\config.py", line 118, in create
cls = getattr(mod, cls_name)
AttributeError: module 'articles.apps' has no attribute 'ArticleConfig'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "manage.py", line 21, in <module>
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "C:\Users\Таирлан\AppData\Local\Programs\Python\Python38-32\lib\site-pack
ages\django\core\management\__init__.py", line 381, in execute_from_command_line
utility.execute()
File "C:\Users\Таирлан\AppData\Local\Programs\Python\Python38-32\lib\site-pack
ages\django\core\management\__init__.py", line 357, in execute
django.setup()
File "C:\Users\Таирлан\AppData\Local\Programs\Python\Python38-32\lib\site-pack
ages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\Таирлан\AppData\Local\Programs\Python\Python38-32\lib\site-pack
ages\django\apps\registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "C:\Users\Таирлан\AppData\Local\Programs\Python\Python38-32\lib\site-pack
ages\django\apps\config.py", line 132, in create
raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: 'articles.apps' does not contain a
class 'ArticleConfig'. Choices are: 'ArticlesConfig'.
D:\Django\myfirst>
ArticlesConfig
, а вINSTALLED_APPS
добавленarticles.apps.ArticleConfig
. Буквыs
не хватает. Вам, кстати об этом и говорит ошибкаdjango.core.exceptions.ImproperlyConfigured: 'articles.apps' does not contain a class 'ArticleConfig'. Choices are: 'ArticlesConfig'.