django oscar AppNotFoundError - python

Im following this tutorial step by step:
http://django-oscar.readthedocs.org/en/releases-1.1/internals/getting_started.html#install-oscar-and-its-dependencies
the thing is when I run the server locally and connect to localhost:8000, I just get this error
Traceback (most recent call last):
File "/usr/lib64/python3.5/wsgiref/handlers.py", line 137, in run
self.result = application(self.environ, self.start_response)
File "/home/hit/projects/quesos/oscar/lib/python3.5/site-packages/django/contrib/staticfiles/handlers.py", line 63, in __call__
return self.application(environ, start_response)
File "/home/hit/projects/quesos/oscar/lib/python3.5/site-packages/django/core/handlers/wsgi.py", line 170, in __call__
self.load_middleware()
File "/home/hit/projects/quesos/oscar/lib/python3.5/site-packages/django/core/handlers/base.py", line 50, in load_middleware
mw_class = import_string(middleware_path)
File "/home/hit/projects/quesos/oscar/lib/python3.5/site-packages/django/utils/module_loading.py", line 26, in import_string
module = import_module(module_path)
File "/home/hit/projects/quesos/oscar/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 662, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "/home/hit/projects/quesos/oscar/lib/python3.5/site-packages/oscar/apps/basket/middleware.py", line 8, in <module>
Applicator = get_class('offer.utils', 'Applicator')
File "/home/hit/projects/quesos/oscar/lib/python3.5/site-packages/oscar/core/loading.py", line 29, in get_class
return get_classes(module_label, [classname])[0]
File "/home/hit/projects/quesos/oscar/lib/python3.5/site-packages/oscar/core/loading.py", line 91, in get_classes
installed_apps_entry, app_name = _find_installed_apps_entry(module_label)
File "/home/hit/projects/quesos/oscar/lib/python3.5/site-packages/oscar/core/loading.py", line 197, in _find_installed_apps_entry
"Couldn't find an app to import %s from" % module_label)
oscar.core.exceptions.AppNotFoundError: Couldn't find an app to import offer.utils from
I'm not sure how to make it work. Can any one help?
Thanks.

You have to append Oscar’s core apps to the installed apps, for example:
from oscar import get_core_apps
INSTALLED_APPS = [
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.flatpages',
...
'compressor',
'widget_tweaks',
] + get_core_apps()

Related

Django: Accessing reusable app in settings.py

I have a reusable django app installed in my project, and the desired outcome is to import it into the main project's settings.py.
The project runs well with the reusable app installed and added into INSTALLED APPS in settings.py.
However, when I try to import it in settings.py, django throws an error.
#import statement
from config_table.models import *
INSTALLED_APPS = [
'django.contrib.contenttypes',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
..., #other apps
'config_table', #reusable app
... #other apps
]
Error Traceback:
Traceback (most recent call last):
File "C:\Users\repo\Auth\auth\manage.py", line 22, in <module>
main()
File "C:\Users\repo\Auth\auth\manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "C:\Users\repo\Auth\auth\venv\lib\site-packages\django\core\management\__init__.py", line 446, in execute_from_command_line
utility.execute()
File "C:\Users\repo\Auth\auth\venv\lib\site-packages\django\core\management\__init__.py", line 386, in execute
settings.INSTALLED_APPS
File "C:\Users\repo\Auth\auth\venv\lib\site-packages\django\conf\__init__.py", line 87, in __getattr__
self._setup(name)
File "C:\Users\repo\Auth\auth\venv\lib\site-packages\django\conf\__init__.py", line 74, in _setup
self._wrapped = Settings(settings_module)
File "C:\Users\repo\Auth\auth\venv\lib\site-packages\django\conf\__init__.py", line 183, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "C:\Python310\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "C:\Users\repo\Auth\auth\auth\settings.py", line 52, in <module>
from config_table.models import *
File "C:\Users\repo\Auth\auth\venv\lib\site-packages\config_table\models.py", line 1, in <module>
from django.contrib.auth.models import User
File "C:\Users\repo\Auth\auth\venv\lib\site-packages\django\contrib\auth\models.py", line 3, in <module>
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
File "C:\Users\repo\Auth\auth\venv\lib\site-packages\django\contrib\auth\base_user.py", line 49, in <module>
class AbstractBaseUser(models.Model):
File "C:\Users\repo\Auth\auth\venv\lib\site-packages\django\db\models\base.py", line 127, in __new__
app_config = apps.get_containing_app_config(module)
File "C:\Users\repo\Auth\auth\venv\lib\site-packages\django\apps\registry.py", line 260, in get_containing_app_config
self.check_apps_ready()
File "C:\Users\repo\Auth\auth\venv\lib\site-packages\django\apps\registry.py", line 138, in check_apps_ready
raise AppRegistryNotReady("Apps aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
I think it has something to do with Django not loading the reusable app in time before the imports, but I'm not sure how to solve this.
Any suggestions are much appreciated!

Django ModuleNotFoundError all of a sudden

All of a sudden, my django project is not working anymore. Not only my actual branch but even master. This happened after coming back to my project after the night. The error I have is when I run any command I have this message :
ModuleNotFoundError: No module named 'pur_beurre.pur_beurre'
(Note : pur_beurre is the name of my project)
When I run python manage.py, I have the list of all possible commands plus this new message in red :
Note that only Django core commands are listed as settings are not properly configured (error: No module named 'pur_beurre.pur_beurre').
I tried to put pur_beurre and pur_beurre.pur_beurre in my installed app in settings.py but its not working.
PS C:\Users\tdechanet.TWM\Documents\OpenClassrooms\p8\code\pur_beurre> python .\manage.py runserver
Traceback (most recent call last):
File "C:\Users\tdechanet.TWM\Documents\OpenClassrooms\p8\code\.venv\lib\site-packages\django\core\management\base.py", line 373, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\tdechanet.TWM\Documents\OpenClassrooms\p8\code\.venv\lib\site-packages\django\core\management\commands\runserver.py", line 66, in execute
super().execute(*args, **options)
File "C:\Users\tdechanet.TWM\Documents\OpenClassrooms\p8\code\.venv\lib\site-packages\django\core\management\base.py", line 417, in execute
output = self.handle(*args, **options)
File "C:\Users\tdechanet.TWM\Documents\OpenClassrooms\p8\code\.venv\lib\site-packages\django\core\management\commands\runserver.py", line 73, in handle
if not settings.DEBUG and not settings.ALLOWED_HOSTS:
File "C:\Users\tdechanet.TWM\Documents\OpenClassrooms\p8\code\.venv\lib\site-packages\django\conf\__init__.py", line 84, in __getattr__
self._setup(name)
File "C:\Users\tdechanet.TWM\Documents\OpenClassrooms\p8\code\.venv\lib\site-packages\django\conf\__init__.py", line 71, in _setup
self._wrapped = Settings(settings_module)
File "C:\Users\tdechanet.TWM\Documents\OpenClassrooms\p8\code\.venv\lib\site-packages\django\conf\__init__.py", line 179, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "C:\Users\tdechanet.TWM\AppData\Local\Programs\Python\Python38-32\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'pur_beurre.pur_beurre'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File ".\manage.py", line 22, in <module>
main()
File ".\manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "C:\Users\tdechanet.TWM\Documents\OpenClassrooms\p8\code\.venv\lib\site-packages\django\core\management\__init__.py", line 425, in execute_from_command_line
utility.execute()
File "C:\Users\tdechanet.TWM\Documents\OpenClassrooms\p8\code\.venv\lib\site-packages\django\core\management\__init__.py", line 419, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\tdechanet.TWM\Documents\OpenClassrooms\p8\code\.venv\lib\site-packages\django\core\management\base.py", line 386, in run_from_argv
connections.close_all()
File "C:\Users\tdechanet.TWM\Documents\OpenClassrooms\p8\code\.venv\lib\site-packages\django\db\utils.py", line 208, in close_all
for alias in self:
File "C:\Users\tdechanet.TWM\Documents\OpenClassrooms\p8\code\.venv\lib\site-packages\django\utils\connection.py", line 73, in __iter__
return iter(self.settings)
File "C:\Users\tdechanet.TWM\Documents\OpenClassrooms\p8\code\.venv\lib\site-packages\django\utils\functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\tdechanet.TWM\Documents\OpenClassrooms\p8\code\.venv\lib\site-packages\django\utils\connection.py", line 45, in settings
self._settings = self.configure_settings(self._settings)
File "C:\Users\tdechanet.TWM\Documents\OpenClassrooms\p8\code\.venv\lib\site-packages\django\db\utils.py", line 144, in configure_settings
databases = super().configure_settings(databases)
File "C:\Users\tdechanet.TWM\Documents\OpenClassrooms\p8\code\.venv\lib\site-packages\django\utils\connection.py", line 50, in configure_settings
settings = getattr(django_settings, self.settings_name)
File "C:\Users\tdechanet.TWM\Documents\OpenClassrooms\p8\code\.venv\lib\site-packages\django\conf\__init__.py", line 84, in __getattr__
self._setup(name)
File "C:\Users\tdechanet.TWM\Documents\OpenClassrooms\p8\code\.venv\lib\site-packages\django\conf\__init__.py", line 71, in _setup
self._wrapped = Settings(settings_module)
File "C:\Users\tdechanet.TWM\Documents\OpenClassrooms\p8\code\.venv\lib\site-packages\django\conf\__init__.py", line 179, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "C:\Users\tdechanet.TWM\AppData\Local\Programs\Python\Python38-32\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'pur_beurre.pur_beurre'
Here is my installed apps :
INSTALLED_APPS = [
'main_site.apps.MainSiteConfig',
'user_management.apps.UserManagementConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
the first line in manage.py is
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'pur_beurre.settings')
which sets the standard path to settings BUT only as default if DJANGO_SETTINGS_MODULE has not been defined on system level.
Your error message looks like you have defined on windows a environement variabel DJANGO_SETTINGS_MODULE="pur_beurre.pur_beurre"
just to check add this line in manage.py at the beginning:
print(os.environ['DJANGO_SETTINGS_MODULE'])
Then check windows settings for the variabel, correct or delete and just in case reboot.

ImportError: cannot import name 'DEFAULT_CURRENCY' from 'moneyed' on Ubuntu

I've been using Django for just over a year for the development of an automation software and am currently just running the project locally on my windows machine.
I hadn't run into any issues with it, until I tried running cron tasks, which ofc windows doesn't support. Scheduled tasks don't work the same way imo, so I installed a Ubuntu VM to work with the project.
Set everything up correctly(I think?), installed Django and all. Currently installing all the libraries the project uses, one of which is django-money. I have installed it, as well as py-moneyed, yet on trying to make migrations, or run the server, I run into this error
enter image description here
Can't find anything about this online. The project still works perfectly with the windows command prompt, as well as PowerShell but having this issue on the ubuntu VM.
Installed apps on my settings.py look like:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'bootstrap5',
'sass_processor',
'djmoney',
'background_task',
'django_crontab',
'companies',
'google_cal',
'dashboard',
]
Any help on this, or good alternative for corn tasks-need some to run every 2 hours and update the db and others to run once a day at a specific time. Celery also does not work with Windows.
The full error is:
Traceback (most recent call last):
File "/mnt/f/Django/RC/Sales-automation/sales-automation/ubuntu_venv
/lib/python3.8/site-packages/django/core/management/base.py", line 354, in run_from_argv self.execute(*args, **cmd_options)
File "/mnt/f/Django/RC/Sales-automation/sales-automation/ubuntu_venv/lib/python3.8/site-packages/django/core/management/commands/runserver.py", line 61, in execute super().execute(*args, **options)
File "/mnt/f/Django/RC/Sales-automation/sales-automation/ubuntu_venv/lib/python3.8/site-packages/django/core/management/base.py", line 398, in execute output = self.handle(*args, **options)
File "/mnt/f/Django/RC/Sales-automation/sales-automation/ubuntu_venv/lib/python3.8/site-packages/django/core/management/commands/runserver.py", line 68, in handle if not settings.DEBUG and not settings.ALLOWED_HOSTS:
File "/mnt/f/Django/RC/Sales-automation/sales-automation/ubuntu_venv/lib/python3.8/site-packages/django/conf/__init__.py", line 82, in __getattr__ self._setup(name)
File "/mnt/f/Django/RC/Sales-automation/sales-automation/ubuntu_venv/lib/python3.8/site-packages/django/conf/__init__.py", line 69, in _setup self._wrapped = Settings(settings_module)
File "/mnt/f/Django/RC/Sales-automation/sales-automation/ubuntu_venv/lib/python3.8/site-packages/django/conf/__init__.py", line 170, in __init__ mod =
importlib.import_module(self.SETTINGS_MODULE)
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 848, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/mnt/f/Django/RC/Sales-automation/sales-automation/automation_software/automation_software/settings.py", line 16, in <module>
from djmoney.settings import FIXER_ACCESS_KEY
File "/mnt/f/Django/RC/Sales-automation/sales-automation/ubuntu_venv/lib/python3.8/site-packages/djmoney/settings.py", line 6, in <module>
from moneyed import CURRENCIES, DEFAULT_CURRENCY, DEFAULT_CURRENCY_CODE
ImportError: cannot import name 'DEFAULT_CURRENCY' from 'moneyed' (/mnt/f/Django/RC/Sales-automation/sales-automation/ubuntu_venv/lib/python3.8/site-packages/moneyed/__init__.py)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "manage.py", line 22, in <module> main()
File "manage.py", line 18, in main execute_from_command_line(sys.argv)
File "/mnt/f/Django/RC/Sales-automation/sales-automation/ubuntu_venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line utility.execute()
File "/mnt/f/Django/RC/Sales-automation/sales-automation/ubuntu_venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 413, in execute self.fetch_command(subcommand).run_from_argv(self.argv)
File "/mnt/f/Django/RC/Sales-automation/sales-automation/ubuntu_venv/lib/python3.8/site-packages/django/core/management/base.py", line 367, in run_from_argv connections.close_all()
File "/mnt/f/Django/RC/Sales-automation/sales-automation/ubuntu_venv/lib/python3.8/site-packages/django/db/utils.py", line 208, in close_all for alias in self:
File "/mnt/f/Django/RC/Sales-automation/sales-automation/ubuntu_venv/lib/python3.8/site-packages/django/utils/connection.py", line 73, in __iter__ return
iter(self.settings)
File "/mnt/f/Django/RC/Sales-automation/sales-automation/ubuntu_venv/lib/python3.8/site-packages/django/utils/functional.py", line 48, in __get__ res = instance.__dict__[self.name] = self.func(instance)
File "/mnt/f/Django/RC/Sales-automation/sales-automation/ubuntu_venv/lib/python3.8/site-packages/django/utils/connection.py", line 45, in
settings self._settings =
self.configure_settings(self._settings)
File "/mnt/f/Django/RC/Sales-automation/sales-automation/ubuntu_venv/lib/python3.8/site-packages/django/db/utils.py", line 144, in configure_settings databases =
super().configure_settings(databases)
File "/mnt/f/Django/RC/Sales-automation/sales-automation/ubuntu_venv/lib/python3.8/site-packages/django/utils/connection.py", line 50, in configure_settings settings = getattr(django_settings, self.settings_name)
File "/mnt/f/Django/RC/Sales-automation/sales-automation/ubuntu_venv/lib/python3.8/site-packages/django/conf/__init__.py", line 82, in __getattr__ self._setup(name)
File "/mnt/f/Django/RC/Sales-automation/sales-automation/ubuntu_venv/lib/python3.8/site-packages/django/conf/__init__.py", line 69, in _setup self._wrapped = Settings(settings_module)
File "/mnt/f/Django/RC/Sales-automation/sales-automation/ubuntu_venv/lib/python3.8/site-packages/django/conf/__init__.py", line 170, in __init__ mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 848, in exec_module
File "<frozen importlib._bootstrap>", line 219, in
_call_with_frames_removed
File "/mnt/f/Django/RC/Sales-automation/sales-automation/automation_software/automation_software/settings.py", line 16, in <module>
from djmoney.settings import FIXER_ACCESS_KEY
File "/mnt/f/Django/RC/Sales-automation/sales-automation/ubuntu_venv/lib/python3.8/site-packages/djmoney/settings.py", line 6, in <module>
from moneyed import CURRENCIES, DEFAULT_CURRENCY, DEFAULT_CURRENCY_CODE
ImportError: cannot import name 'DEFAULT_CURRENCY' from 'moneyed' (/mnt/f/Django/RC/Sales-automation/sales-automation/ubuntu_venv/lib/python3.8/site-packages/moneyed/__init__.py)
That constant has been removed in version 2.0. See this link https://github.com/py-moneyed/py-moneyed/blob/ef5d65da3e6e774a377b6e1434a051f0454d2193/CHANGES.rst

Django: No module named 'project'

I was working on a Django project on my personal laptop. Then I cloned the project to my work laptop and I'm getting a very weird error when I try to run any command, such as python manage.py runserver:
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 "/Users/jmetz/github/personal/golf-swings-api/venv/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/Users/jmetz/github/personal/golf-swings-api/venv/lib/python3.7/site-packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/jmetz/github/personal/golf-swings-api/venv/lib/python3.7/site-packages/django/core/management/base.py", line 336, in run_from_argv
connections.close_all()
File "/Users/jmetz/github/personal/golf-swings-api/venv/lib/python3.7/site-packages/django/db/utils.py", line 219, in close_all
for alias in self:
File "/Users/jmetz/github/personal/golf-swings-api/venv/lib/python3.7/site-packages/django/db/utils.py", line 213, in __iter__
return iter(self.databases)
File "/Users/jmetz/github/personal/golf-swings-api/venv/lib/python3.7/site-packages/django/utils/functional.py", line 80, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/Users/jmetz/github/personal/golf-swings-api/venv/lib/python3.7/site-packages/django/db/utils.py", line 147, in databases
self._databases = settings.DATABASES
File "/Users/jmetz/github/personal/golf-swings-api/venv/lib/python3.7/site-packages/django/conf/__init__.py", line 79, in __getattr__
self._setup(name)
File "/Users/jmetz/github/personal/golf-swings-api/venv/lib/python3.7/site-packages/django/conf/__init__.py", line 66, in _setup
self._wrapped = Settings(settings_module)
File "/Users/jmetz/github/personal/golf-swings-api/venv/lib/python3.7/site-packages/django/conf/__init__.py", line 157, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/Users/jmetz/miniconda3/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'project'
Any idea what the issue is?
Add project to your INSTALLED_APPS in settings.py file
settings.py
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'project',
]
My solution to a similar problem was to export PYTHONPATH into my shell. That was throwing a warning about project, even though the INSTALLED_APPS was correct.

python - django error "RuntimeError: doesn't declare an explicit app_label"

I am struggling with a problem in using django. When I type python manage.py runserver, it holds for few seconds and keeps giving me a following message:
RuntimeError: Model class upload.models.ImgParent doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.
I searched similar problems on the internet and tried to add 'upload.models.ImgParent' on INSTALLED_APPS in settings.py but it still doesn't work.
My current INSTALLED_APPS in settings.py looks like this:
INSTALLED_APPS = [
'search.apps.SearchConfig',
'upload.apps.UploadConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django_extensions',
'mod_wsgi.server',
'home',
]
and my apps.py looks like this:
class UploadConfig(AppConfig):
name = 'upload'
edit, this is full traceback:
Traceback (most recent call last):
File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/usr/lib/python3.6/threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "/home/edwardkim/syseng/venv/lib/python3.6/site-packages/django/utils/autoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "/home/edwardkim/syseng/venv/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 109, in inner_run
autoreload.raise_last_exception()
File "/home/edwardkim/syseng/venv/lib/python3.6/site-packages/django/utils/autoreload.py", line 77, in raise_last_exception
raise _exception[0](_exception[1]).with_traceback(_exception[2])
File "/home/edwardkim/syseng/venv/lib/python3.6/site-packages/django/utils/autoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "/home/edwardkim/syseng/venv/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/edwardkim/syseng/venv/lib/python3.6/site-packages/django/apps/registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "/home/edwardkim/syseng/venv/lib/python3.6/site-packages/django/apps/config.py", line 134, in create
% (mod_path, cls_name, ', '.join(candidates))
django.core.exceptions.ImproperlyConfigured: 'upload.apps' does not contain a class 'uploadConfig'. Choices are: 'UploadConfig'.
Traceback (most recent call last):
File "manage.py", line 19, in <module>
execute_from_command_line(sys.argv)
File "/home/edwardkim/syseng/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/home/edwardkim/syseng/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/edwardkim/syseng/venv/lib/python3.6/site-packages/django/core/management/base.py", line 323, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/edwardkim/syseng/venv/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 60, in execute
super().execute(*args, **options)
File "/home/edwardkim/syseng/venv/lib/python3.6/site-packages/django/core/management/base.py", line 364, in execute
output = self.handle(*args, **options)
File "/home/edwardkim/syseng/venv/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 95, in handle
self.run(**options)
File "/home/edwardkim/syseng/venv/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 102, in run
autoreload.run_with_reloader(self.inner_run, **options)
File "/home/edwardkim/syseng/venv/lib/python3.6/site-packages/django/utils/autoreload.py", line 579, in run_with_reloader
start_django(reloader, main_func, *args, **kwargs)
File "/home/edwardkim/syseng/venv/lib/python3.6/site-packages/django/utils/autoreload.py", line 564, in start_django
reloader.run(django_main_thread)
File "/home/edwardkim/syseng/venv/lib/python3.6/site-packages/django/utils/autoreload.py", line 272, in run
get_resolver().urlconf_module
File "/home/edwardkim/syseng/venv/lib/python3.6/site-packages/django/utils/functional.py", line 80, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/edwardkim/syseng/venv/lib/python3.6/site-packages/django/urls/resolvers.py", line 564, in urlconf_module
return import_module(self.urlconf_name)
File "/home/edwardkim/syseng/venv/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/edwardkim/syseng/Foram_Tagger_Team43_Software/projectsite/projectsite/urls.py", line 23, in <module>
path('search/', include('search.urls')),
File "/home/edwardkim/syseng/venv/lib/python3.6/site-packages/django/urls/conf.py", line 34, in include
urlconf_module = import_module(urlconf_module)
File "/home/edwardkim/syseng/venv/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/edwardkim/syseng/Foram_Tagger_Team43_Software/projectsite/search/urls.py", line 3, in <module>
from . import views
File "/home/edwardkim/syseng/Foram_Tagger_Team43_Software/projectsite/search/views.py", line 2, in <module>
from upload.models import Img
File "/home/edwardkim/syseng/Foram_Tagger_Team43_Software/projectsite/upload/models.py", line 3, in <module>
class ImgParent(models.Model):
File "/home/edwardkim/syseng/venv/lib/python3.6/site-packages/django/db/models/base.py", line 111, in __new__
"INSTALLED_APPS." % (module, name)
RuntimeError: Model class upload.models.ImgParent doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.
Please help with my problem and let me know if you need any additional information. Thank you.

Categories