How to fix heroku app deployment? App runs locally but not online - python

I'm trying to deploy a dog breed classifier django app on heroku, but for some reason heroku doesn't seem to find the path to the exported pkl model file. Whenever I run locally, everything works fine. I'm using the "path" module's "exist()" method to check for the presence of the file first before importing the module, hence the reason for the exception thrown. Image of app file structure
Here's the stack trace for the error:
Environment:
Request Method: GET
Request URL: https://mydogbreed.herokuapp.com/
Django Version: 3.2.5
Python Version: 3.9.6
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'api.apps.ApiConfig',
'corsheaders',
'frontend']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'corsheaders.middleware.CorsMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware']
Traceback (most recent call last):
File "/app/.heroku/python/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/app/.heroku/python/lib/python3.9/site-packages/django/core/handlers/base.py", line 167, in _get_response
callback, callback_args, callback_kwargs = self.resolve_request(request)
File "/app/.heroku/python/lib/python3.9/site-packages/django/core/handlers/base.py", line 290, in resolve_request
resolver_match = resolver.resolve(request.path_info)
File "/app/.heroku/python/lib/python3.9/site-packages/django/urls/resolvers.py", line 556, in resolve
for pattern in self.url_patterns:
File "/app/.heroku/python/lib/python3.9/site-packages/django/utils/functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/app/.heroku/python/lib/python3.9/site-packages/django/urls/resolvers.py", line 598, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/app/.heroku/python/lib/python3.9/site-packages/django/utils/functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/app/.heroku/python/lib/python3.9/site-packages/django/urls/resolvers.py", line 591, in urlconf_module
return import_module(self.urlconf_name)
File "/app/.heroku/python/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
<source code not available>
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
<source code not available>
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
<source code not available>
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
<source code not available>
File "<frozen importlib._bootstrap_external>", line 850, in exec_module
<source code not available>
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
<source code not available>
File "/app/breed_classifier/urls.py", line 6, in <module>
from api import views
File "/app/api/views.py", line 38, in <module>
raise Exception("Model path doesn't exist")
Exception Type: Exception at /
Exception Value: Model path doesn't exist

Related

django import export app error: django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet

I'm upgrading a Django site to 3.1.2 and noticed one backend app wasn't working, in the process of asking the community help in fixing this I found out the app wasn't a custom made code by a single coder for the site but a community project called django-import-export. Since it's up to date and supports django 3.1 i deleted the manual way it was setup as a folder and pip installed it. i then tried to do a makemigrations threw an error and after reading the setup docs assumed possibly you need to do collectstatic first, it also threw the same error
(kpsga) sammy#kpsga:~/webapps/kpsga$ python manage.py collectstatic
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 "/home/sammy/webapps/envs/kpsga/lib/python3.8/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
utility.execute()
File "/home/sammy/webapps/envs/kpsga/lib/python3.8/site-packages/django/core/management/__init__.py", line 377, in execute
django.setup()
File "/home/sammy/webapps/envs/kpsga/lib/python3.8/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/sammy/webapps/envs/kpsga/lib/python3.8/site-packages/django/apps/registry.py", line 114, in populate
app_config.import_models()
File "/home/sammy/webapps/envs/kpsga/lib/python3.8/site-packages/django/apps/config.py", line 211, in import_models
self.models_module = import_module(models_module_name)
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 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/sammy/webapps/kpsga/guides/models.py", line 77, in <module>
class GuideResource(resources.ModelResource):
File "/home/sammy/webapps/envs/kpsga/lib/python3.8/site-packages/import_export/resources.py", line 930, in __new__
field = new_class.field_from_django_field(f.name, f,
File "/home/sammy/webapps/envs/kpsga/lib/python3.8/site-packages/import_export/resources.py", line 1079, in field_from_django_field
FieldWidget = cls.widget_from_django_field(django_field)
File "/home/sammy/webapps/envs/kpsga/lib/python3.8/site-packages/import_export/resources.py", line 1045, in widget_from_django_field
result = getattr(cls, result)(f)
File "/home/sammy/webapps/envs/kpsga/lib/python3.8/site-packages/import_export/resources.py", line 1025, in get_fk_widget
model=get_related_model(field))
File "/home/sammy/webapps/envs/kpsga/lib/python3.8/site-packages/import_export/resources.py", line 49, in get_related_model
if hasattr(field, 'related_model'):
File "/home/sammy/webapps/envs/kpsga/lib/python3.8/site-packages/django/utils/functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/sammy/webapps/envs/kpsga/lib/python3.8/site-packages/django/db/models/fields/related.py", line 95, in related_model
apps.check_models_ready()
File "/home/sammy/webapps/envs/kpsga/lib/python3.8/site-packages/django/apps/registry.py", line 141, in check_models_ready
raise AppRegistryNotReady("Models aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet.
this somehow is related to installed_apps so I've included the entire list below
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
#site apps
'guides',
'pages',
#imported old dependencies
'blog',
'import_export',
'generic',
#imports
'comments_moderation',
'django_comments',
'sorl.thumbnail',
#additional django
'django.contrib.sites',
'django.contrib.humanize',
]
The traceback shows that the error occurs when loading GuideResource in your models.py.
The getting started docs for django-import-export suggest putting the resource in the admin.py, so I would try moving the GuideResource outside of models.py.

Pyo Python DSP Module Won't Deploy to Heroku

So I'm trying to put up a demo of a django project on Heroku that runs fine locally and loads when I uninstall the package Pyo, but it throws an OSerror when I reinstall it (OSError at /
Exception Value: /app/.pyo/3.6_64/libs/libasound-fb332ab3.so.2.0.0: cannot open shared object -- see below for full traceback). I've added a buildpack that installs the libasound and recommened packages, but I still get the error. What am I missing? I see the Linux wheel fix symlink (https://github.com/belangeo/pyo/blob/master/pyo/_linux_wheel_fix_symlinks.py). Is the issue here? Any help greatly appreciated.
Error:
Request Method: GET
Request URL: ---
Django Version: 3.0.3
Python Version: 3.6.10
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'core',
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.facebook',
'allauth.socialaccount.providers.google']
Installed Middleware:
('whitenoise.middleware.WhiteNoiseMiddleware',
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware')
Traceback (most recent call last):
File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/base.py", line 100, in _get_response
resolver_match = resolver.resolve(request.path_info)
File "/app/.heroku/python/lib/python3.6/site-packages/django/urls/resolvers.py", line 544, in resolve
for pattern in self.url_patterns:
File "/app/.heroku/python/lib/python3.6/site-packages/django/utils/functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/app/.heroku/python/lib/python3.6/site-packages/django/urls/resolvers.py", line 588, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/app/.heroku/python/lib/python3.6/site-packages/django/utils/functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/app/.heroku/python/lib/python3.6/site-packages/django/urls/resolvers.py", line 581, in urlconf_module
return import_module(self.urlconf_name)
File "/app/.heroku/python/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
<source code not available>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
<source code not available>
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
<source code not available>
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
<source code not available>
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
<source code not available>
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
<source code not available>
File "/app/autosubclub/urls.py", line 20, in <module>
from core import views
File "/app/core/views.py", line 8, in <module>
from pyo import PVMix, PVMorph, PVAnal, SfPlayer, Vocoder, Server, Record, sndinfo
File "/app/.heroku/python/lib/python3.6/site-packages/pyo/__init__.py", line 25, in <module>
from . import _linux_wheel_fix_symlinks
File "/app/.heroku/python/lib/python3.6/site-packages/pyo/_linux_wheel_fix_symlinks.py", line 88, in <module>
libasound = ctypes.CDLL(libasound, mode=ctypes.RTLD_GLOBAL)
File "/app/.heroku/python/lib/python3.6/ctypes/__init__.py", line 348, in __init__
self._handle = _dlopen(self._name, mode)
Exception Type: OSError at /
Exception Value: /app/.pyo/3.6_64/libs/libasound-fb332ab3.so.2.0.0: cannot open shared object file: No such file or directory
I just want to leave this for anyone else who experiences this issue in the future. Pyo will not work on a hobby dev Heroku DYNO due to the symlink wheels created that attempt to reach out of the ./app folder for ibasound-fb332ab3.so.2.0.0 and libjack-07a61c7b.so.0.1.0, but Heroku apps can't reach out of that directory because it's where everything is stored.
You can install on other cloud environments like Digital Ocean & Amazon EC2 where you can install Ubuntu on the server and have full access. I chose Digital Ocean for a while, but ended up just teaching the client how to run the web app locally and writing code to push the generated files to Amazon s3.

Apps not ready yet, upgrading to Django 1.9 and then to 2.0

I am trying to upgrade my Django project to Django 2.0, currently the version is 1.8.19. I figured I would do it step by step, firstly upgrading to 1.9, then 1.10 and so on till 2.0. The problem is that I get error message
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/riddle/tmp1/example-project/env/lib/python3.6/site-packages/django/core/management/__init__.py", line 350, in execute_from_command_line
utility.execute()
File "/home/riddle/tmp1/example-project/env/lib/python3.6/site-packages/django/core/management/__init__.py", line 302, in execute
settings.INSTALLED_APPS
File "/home/riddle/tmp1/example-project/env/lib/python3.6/site-packages/django/conf/__init__.py", line 55, in __getattr__
self._setup(name)
File "/home/riddle/tmp1/example-project/env/lib/python3.6/site-packages/django/conf/__init__.py", line 43, in _setup
self._wrapped = Settings(settings_module)
File "/home/riddle/tmp1/example-project/env/lib/python3.6/site-packages/django/conf/__init__.py", line 99, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/home/riddle/tmp1/example-project/env/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/riddle/tmp1/example-project/app/ad_akumuliatoriai_lt/settings.py", line 140, in <module>
from apps.frontend.ad_akumuliatoriai.models import Language
File "/home/riddle/tmp1/example-project/app/apps/frontend/ad_akumuliatoriai/models.py", line 5, in <module>
from ordered_model.models import OrderedModel
File "/home/riddle/tmp1/example-project/env/lib/python3.6/site-packages/ordered_model/models.py", line 20, in <module>
class OrderedModelBase(models.Model):
File "/home/riddle/tmp1/example-project/env/lib/python3.6/site-packages/django/db/models/base.py", line 94, in __new__
app_config = apps.get_containing_app_config(module)
File "/home/riddle/tmp1/example-project/env/lib/python3.6/site-packages/django/apps/registry.py", line 239, in get_containing_app_config
self.check_apps_ready()
File "/home/riddle/tmp1/example-project/env/lib/python3.6/site-packages/django/apps/registry.py", line 124, in check_apps_ready
raise AppRegistryNotReady("Apps aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
I have read the thread: Django upgrading to 1.9 error "AppRegistryNotReady: Apps aren't loaded yet."
I have tried using
import django
django.setup()
at the top of my settings.py file with no luck.
I've made an assumption that the problem is with the third party apps.
My main question is, how to start checking for invalid third party apps, since commenting them out one by one does not remove the error. I've checked every app's that I've installed via pip documentation, and added the required lines
to the INSTALLED_APPS in settings.py. It seems that some packages, such as django-jquery, django-libsass, django-ordered-model have not been developed for some years, however, according to django==1.9 release date, those apps should have worked on django==1.9 (or maybe that is the mistake of my thinking?).
I am ready to post more information from my project if needed.
My settings.py fragment:
INSTALLED_APPS = (
'hvad',
'compressor',
'filebrowser',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'jquery',
'tinymce',
'apps.frontend.ad_akumuliatoriai',
'ordered_model',
'geoposition',
)
The output of "pip freeze":
Django==1.9
django-appconf==1.0.2
django-compressor==2.2
django-filebrowser-no-grappelli==3.7.4
django-geoposition==0.3.0
django-hvad==1.8.0
django-jquery==3.1.0
django-libsass==0.7
django-ordered-model==1.4.3
django-tinymce==2.7.0
libsass==0.14.2
Pillow==5.1.0
psycopg2==2.7.4
pytz==2018.3
rcssmin==1.0.6
rjsmin==1.0.12
six==1.11.0
The traceback suggests you are importing a model in your settings.py:
from apps.frontend.ad_akumuliatoriai.models import Language
You shouldn't do this. Remove the import.

Django 1.10 python 3.5 django-admin-tools

I am using Django 1.10 and installed django-admin-tools. Settings look like this:
INSTALLED_APPS = [
'admin_tools',
'admin_tools.theming',
'admin_tools.menu',
'admin_tools.dashboard',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admindocs',
]
MIDDLEWARE_CLASSES = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'cvix3.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')]
,
'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',
],
'loaders': [
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
'admin_tools.template_loaders.Loader',
]
},
},
]
Next I am trying to run
python3 ./manage.py migrate
But this gives me an error.
python3 ./manage.py migrate
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.5/dist-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.5/dist-packages/django/core/management/__init__.py", line 359, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python3.5/dist-packages/django/core/management/base.py", line 305, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python3.5/dist-packages/django/core/management/base.py", line 353, in execute
self.check()
File "/usr/local/lib/python3.5/dist-packages/django/core/management/base.py", line 385, in check
include_deployment_checks=include_deployment_checks,
File "/usr/local/lib/python3.5/dist-packages/django/core/management/commands/migrate.py", line 62, in _run_checks
issues.extend(super(Command, self)._run_checks(**kwargs))
File "/usr/local/lib/python3.5/dist-packages/django/core/management/base.py", line 372, in _run_checks
return checks.run_checks(**kwargs)
File "/usr/local/lib/python3.5/dist-packages/django/core/checks/registry.py", line 81, in run_checks
new_errors = check(app_configs=app_configs)
File "/usr/local/lib/python3.5/dist-packages/django/core/checks/urls.py", line 14, in check_url_config
return check_resolver(resolver)
File "/usr/local/lib/python3.5/dist-packages/django/core/checks/urls.py", line 24, in check_resolver
for pattern in resolver.url_patterns:
File "/usr/local/lib/python3.5/dist-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/usr/local/lib/python3.5/dist-packages/django/urls/resolvers.py", line 310, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/usr/local/lib/python3.5/dist-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/usr/local/lib/python3.5/dist-packages/django/urls/resolvers.py", line 303, in urlconf_module
return import_module(self.urlconf_name)
File "/usr/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 665, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "/home/dick/PycharmProjects/cvix3/cvix3/urls.py", line 20, in <module>
url(r'^admin_tools/', include('admin_tools.urls'))
File "/usr/local/lib/python3.5/dist-packages/django/conf/urls/__init__.py", line 50, in include
urlconf_module = import_module(urlconf_module)
File "/usr/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 665, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "/usr/local/lib/python3.5/dist-packages/admin_tools/urls.py", line 2, in <module>
from django.conf.urls import patterns, url, include
ImportError: cannot import name 'patterns'
It looks like an incompatibility between Django 1.9 and 1.10 but I am not sure. Anybody an idea?
Cheers...
It looks like you are running Django 1.10, not 1.9 as you originally said. In Django 1.10, patterns has been removed (release notes).
The issue has been fixed in django-admin-tools, but it looks like there hasn't been a release yet. It should work fine with Django 1.9 for now.
It was indeed 1.10
After downloading from github install migrate ran perfectly.
However.....
When I try to get the dashboard I get a 404
http://127.0.0.1:8000/dashboard/
Using the URLconf defined in cvixweb.urls, Django tried these URL patterns, in this order:
1. ^admin_tools/ ^menu/
2. ^admin_tools/ ^dashboard/ ^set_preferences/(?P<dashboard_id>.+)/$ [name='admin-tools-dashboard-set-preferences']

django oscar AppNotFoundError

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()

Categories