ewok
ewok

Reputation: 21453

Django upgrade from 1.4 to 1.8

I'm trying to upgrade a project from Django 1.4 to 1.8. I've adjusted the app definitions as the docs say to:

wm/apps.py:

from django.apps import AppConfig

class WMConfig(AppConfig):
    name="wm"
    verbose_name="WebManager"

wm/__init__.py:

default_app_config = 'wm.apps.WMConfig'

The issue is now when I try to access the app through a browser I get a 500 error. The Apache logs show:

 mod_wsgi (pid=33242): Target WSGI script '/home/admusr/project/WebManager/wsgi.py' cannot be loaded as Python module.
 mod_wsgi (pid=33242): Exception occurred processing WSGI script '/home/admusr/project/WebManager/wsgi.py'.
 Traceback (most recent call last):
   File "/home/admusr/project/WebManager/wsgi.py", line 24, in <module>
     application = get_wsgi_application()
   File "/usr/local/lib/python2.7/dist-packages/django/core/wsgi.py", line 14, in get_wsgi_application
     django.setup()
   File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line 18, in setup
     apps.populate(settings.INSTALLED_APPS)
   File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", line 85, in populate
     app_config = AppConfig.create(entry)
   File "/usr/local/lib/python2.7/dist-packages/django/apps/config.py", line 112, in create
     mod = import_module(mod_path)
   File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
     __import__(name)
 ImportError: No module named wm.apps

If I change wm/__init__.py to default_app_config = 'apps.WMConfig' then it just says ImportError: No module named apps, so the issue is when it tried to load that module. I haven't been able to find anything on this with such a generic error message.

Upvotes: 2

Views: 149

Answers (1)

Alasdair
Alasdair

Reputation: 308839

Try

default_app_config = 'Webmanager.wm.apps.WMConfig'

As an aside, the docs recommend that you use the path to the app config directly in INSTALLED_APPS, instead of seeing default_app_config in the app's __init__.py

INSTALLED_APPS = (
    ... 
    'Webmanager.wm.apps.WMConfig', 

)

The other problem is your app config's name attribute. This should be the full path, i.e. WebManager.wm instead of wm.

class WMConfig(AppConfig):
    name="WebManager.wm"
    verbose_name="WebManager"

Upvotes: 2

Related Questions