I'm new to Django and learning my way through while trying to follow best practices. I'm working my way through Two Scoops of Django 3.x. Any questioning of structure should be directed to the authors.
I'm hopeful that the question is solid enough to not be deleted in the first few minutes as I'm really stuck on this one. If this question is to be deleted I would appreciate guidance on how to improve how I ask questions in the future. I've read the how to ask good questions blog and am hopeful I'm following this guidance. If I did miss something please do more than provide a link to the blog.

articles/__init__.py:default_app_config = 'LanesFlow.apps.articles.apps.ArticlesConfig'
articles/apps.py:from django.apps import AppConfig
class ArticlesConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'apps.articles'
class ArticlesConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'LanesFlow.apps.articles' # This was checked per the answer to the researched question
base.py (settings.py):INSTALLED_APPS = [
'apps.articles.ArticlesConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:\Users\Carewen\AppData\Local\Programs\Python\Python39\lib\threading.py", line 954, in _bootstrap_inner
self.run()
File "C:\Users\Carewen\AppData\Local\Programs\Python\Python39\lib\threading.py", line 892, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\Carewen\AppData\Local\Programs\Python\Python39\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "C:\Users\Carewen\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\management\commands\runserver.py", line 110, in inner_run
autoreload.raise_last_exception()
File "C:\Users\Carewen\AppData\Local\Programs\Python\Python39\lib\site-packages\django\utils\autoreload.py", line 87, in raise_last_exception
raise _exception[1]
File "C:\Users\Carewen\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\management\__init__.py", line 375, in execute
autoreload.check_errors(django.setup)()
File "C:\Users\Carewen\AppData\Local\Programs\Python\Python39\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "C:\Users\Carewen\AppData\Local\Programs\Python\Python39\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\Carewen\AppData\Local\Programs\Python\Python39\lib\site-packages\django\apps\registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "C:\Users\Carewen\AppData\Local\Programs\Python\Python39\lib\site-packages\django\apps\config.py", line 221, in create
raise ImportError(msg)
ImportError: Module 'apps.articles' does not contain a 'ArticlesConfig' class.
Any assistance would be welcomed.
I've reverted to the last working version once more. I've found where it goes wrong. When I try to add 'articles.app.ArticleConfig' to INSTALLED_APPS things go wrong. The thing is, this leaves me more confused. I'm trying to add templates. The process I'm following is:
ImportError. However, the apps.py file does contact the class ArticlesConfig(AppConfig)Also in base.py (settings.py):
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [BASE_DIR / 'apps.templates'], # Two scoops add. Was []
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
I remain confused. My inexperience with Django is really showing here. I'm not certain what I'm doing wrong with the addition to INSTALLED_APPS. My instinct is pointing me to exploring other aspects of settings.py to see if I'm pointing someone incorrectly.
The problem seems to be related to:
INSTALLED_APPS = [
'apps.articles.ArticlesConfig',
It should be: 'apps.articles.apps.ArticlesConfig',
Also your Contents of articles/apps.py should be only:
from django.apps import AppConfig
class ArticlesConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'apps.articles'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With