tutuca
tutuca

Reputation: 3670

Dotted name in AppConfig

With django 1.7 they added support for configuration classes instead of the magic string from previous versions.

My project has several applications into a folder named apps which is added to the PYTHON_PATH.

After adding a simple AppConfig derived class I'm running into many import errors and I want to rule out silly mistakes.

Suppose this structure:

project_root/
    my_project/
    apps/
        my_app/
        another_app/

Would it be correct to have this config?:

# my_app/apps.py
class MyAppConfig(AppConfig):
    name = 'apps.my_app'


# my_app/__init__.py
default_app_config='apps.my_app.apps.MyAppConfig'

# settings.py
INSTALLED_APPS = (
    ...
    'apps.myapp.apps.MyAppConfig'
    ...
)

Curently the project fails when trying to import models (or tasks or any other module) issuing:

from apps.my_app.tasks import AwesomeTask

ImportError: no module named my_app.tasks

Upvotes: 1

Views: 715

Answers (1)

idris
idris

Reputation: 187

I solved a similar issue by renaming the apps folder. It was somehow conflicting with Django internals system.

I hope this helps someone.

Upvotes: 1

Related Questions