0

I am getting AttributeError: module "app" has no attributes 'helpers' when I am trying to import as follow in HlperConnector.py:

import app.Helpers.SubHelper as shelpr

Same setup works perfectly on my VSCode but when deploying on Digital Ocen Linux VM (Ubantu 18.04.3 version). Here is my directory structure:

├───app
│   │   admin.py
│   │   apps.py
│   │   forms.py
│   │   tests.py
│   │   urls.py
│   │   __init__.py
│   │
│   ├───Helpers
│   │   │   helper1.py
│   │   │   HelperConnector.py
│   │   │   helper2.py
│   │   │   __init__.py
│   │   ├───SubHelper
│   │   │   │   subhelpers1.py
│   │   │   │   subhelpers2.py
│   │   │   │   __init__.py
└───Project
    │   asgi.py
    │   dosettings.py
    │   settings.py
    │   urls.py
    │   wsgi.py
    │   __init__.py
    │

Can someone please help me to resolve the above issue?

I check the Django version which i use for my development (windows PC) is 3.0.6 and Production environment (Ubantu 18.04) is 3.0.7. But my guess is that this should not be an issue.

Thank You.

DjangoRulz
  • 85
  • 7

1 Answers1

0

First, You should add below code in app.ini.py

default_app_config = 'app.apps.AppConfig'

and, then add this code in app.apps.py

from django.apps import AppConfig

class AppConfig(AppConfig): name = 'app'

then, import will work.

  • Hi and welcome to Stack Overflow! Please take the [tour](https://stackoverflow.com/tour) and read in the [help center](https://stackoverflow.com/editing-help) about how to format code. Thanks for contributing an answer but can you also add an explanation on how it solves the issue? – Jeanne Dark Dec 07 '20 at 09:39