I made 2 projects with django so far and everything smooth.
using python 3.6 and conda env with django 3.1.4
I am following the tutorial to kick off my new project as I did for my previous one : https://docs.djangoproject.com/fr/3.1/intro/tutorial01/
Start a new one using "django-admin startproject ngedemocarto" then used "django startapp sitemanager" it gives me this :
but suddenly in this project I keep having error when I try to call any app module like "apps.py" or "urls.py"
typical error if I add the app config in settings.py like this :
INSTALLED_APPS = [
'sitemanager.apps.SitemanagerConfig'
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
resolve in this error :
ModuleNotFoundError: No module named 'sitemanager.apps.SitemanagerConfigdjango'; 'sitemanager.apps' is not a package
every command like manage.py runserver or manage.py migrate is failing at import because it can't resolve any names like "sitemanager.apps" or "sitemanager.urls"
I checked basic things :
I am in a very basic config just after starting this new project and nothing works ...
I tried to build a new conda env, start a new django project, same thing.
I don't really know where I should look to solve this problem and how to troubleshot it. It may be an issue with the way python import modules and how I use my python env, maybe something wrong in sys.path either
My others project keep working, I can use runserver and migrate for exemple.
EDIT & ANSWER:
well, I was missing a coma for my appconfig and I didn't create urls.py in sitemanager (was only in the main project)....
Guess I should have take a break, thanks.
You have to add a comma after 'sitemanager.apps.SitemanagerConfig'. The lack of a comma has the effect of django trying to find 'sitemanager.apps.SitemanagerConfigdjango', which does not exist:
before:
INSTALLED_APPS = [
'sitemanager.apps.SitemanagerConfig'
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
after:
INSTALLED_APPS = [
'sitemanager.apps.SitemanagerConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
Alternatively, can just add 'sitemanager' instead of 'sitemanager.apps.SitemanagerConfig'