1

I am getting error when I am installing Django Oscar Module in my Project, it's giving me this error

from oscar import get_core_apps
ImportError: cannot import name 'get_core_apps'

Here are my settings.py file...

from oscar import get_core_apps
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'django.contrib.flatpages',
'compressor',
'widget_tweaks',
'south',
] + get_core_apps()

Here are the Error Code Which i am getting on terminal...

    self._databases = settings.DATABASES
 File "/home/amit/.local/lib/python3.6/site-packages/django/conf/__init__.py", line 79, in __getattr__
self._setup(name)
File "/home/amit/.local/lib/python3.6/site-packages/django/conf/__init__.py", line 66, in _setup
self._wrapped = Settings(settings_module)
File "/home/amit/.local/lib/python3.6/site-packages/django/conf/__init__.py", line 157, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/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/amit/Desktop/Django/frobshop/frobshop/settings.py", line 32, in <module>
from oscar import get_core_apps
ImportError: cannot import name 'get_core_apps'
msginfosys
  • 57
  • 11

2 Answers2

2

The get_core_apps has been removed since , as is described in the release notes:

Removed oscar.get_core_apps. Overriding apps is now done by replacing the Oscar app entry in the INSTALLED_APPS setting with that of the forked app.

You thus should remove the get_core_apps, and alter the INSTALLED_APPS instead. For example:

INSTALLED_APPS = [
    # Django apps
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.sites',
    'django.contrib.flatpages',

    # oscar apps
    'oscar',

    # your apps
    # ...
]
Willem Van Onsem
  • 443,496
  • 30
  • 428
  • 555
  • Now I am Getting this error...`ImportError: cannot import name 'OSCAR_MAIN_TEMPLATE_DIR' ` – msginfosys Aug 02 '19 at 10:05
  • @msginfosys: this is part of the release notes as well: *OSCAR_MAIN_TEMPLATE_DIR setting has been removed and existing templates updated with the full path. See #1378, #2250. Please update your templates accordingly.*. – Willem Van Onsem Aug 02 '19 at 10:08
  • I solve this issue after remove the 'OSCAR_MAIN_TEMPLATE_DIR' but now it's giving me another error `ModuleNotFoundError: No module named 'oscar.apps.promotions'`...as you mentioned in your reply i copy the same code and paste in my INSTALLED_APPS – msginfosys Aug 02 '19 at 10:11
  • @msginfosys: perhaps it is better to start with `'oscar'` and just look what apps are necessary? – Willem Van Onsem Aug 02 '19 at 10:13
  • I done it with `oscar` but i got this error...`LookupError: No installed app with label 'catalogue'. ` – msginfosys Aug 02 '19 at 10:16
  • @msginfosys: exactly, you thus will need to add that as well. By iteratively adding, you will eventually reach a minimum fixed point. – Willem Van Onsem Aug 02 '19 at 10:17
  • After adding required apps finally i got this error...`RuntimeError: Model class django.contrib.sites.models.Site doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS. ` – msginfosys Aug 02 '19 at 10:21
  • That's because your `django.contrib.sites.models'` should be in the `INSTALLED_APPS` as well. It is referenced by a model. – Willem Van Onsem Aug 02 '19 at 10:22
  • Now it's not importing anything from `from django.urls import path, include, patterns, url` and giving me this error `ImportError: cannot import name 'url'` – msginfosys Aug 02 '19 at 10:40
  • @msginfosys: `url` has been moved to `django.conf.urls`, so you should remove the `url` import (the last word), and use `from django.conf.urls import url`. It probably might help to read the release notes of the versions you upgraded... – Willem Van Onsem Aug 02 '19 at 10:41
  • Oh My God...It's installing now...all tables has been created in database...Thank You Willem for your Support... – msginfosys Aug 02 '19 at 10:48
  • Hi Willem, I have one more question, Can i implement this Module in my running website... – msginfosys Aug 02 '19 at 10:52
  • @msginfosys: what module? If you alter the settings, etc. you will need to restart the server. See https://docs.djangoproject.com/en/2.2/howto/deployment/ for more info. – Willem Van Onsem Aug 02 '19 at 10:53
  • I mean to say, I want to implement all the functionality of `oscar` in my running website,...and i have some errors when i am login my admin panel also...Getting this error when login my admin panel `DoesNotExist at /admin/login/` – msginfosys Aug 02 '19 at 10:58
  • @WillemVanOnsem I'm getting a similar error : Can you help ! – Earthling Jan 02 '23 at 03:31
0

Looks like 'get_core_apps' does not exists anymore.

Source: https://github.com/django-oscar/django-oscar/pull/2633

krolikmvp
  • 11
  • 2