Search code examples
pythondjangodjango-oscar

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.


Solution

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