I am trying to move all the apps that I have in my Django application to a folder call apps:
The structure that I have right now is:
miApp
-accounts #App folder
-participation #App folder
-administration #App folder
-miapp
--wsgi.py
--urls.py
--settings
---development.py
---production.py
---__init__.py
-static
And I would like to have something like this
miApp
-apps #New folder for the apps
--accounts #App folder
--reputation #App folder
--participation #App folder
--administration #App folder
--__init__.py
-miApp
--wsgi.py
--urls.py
--settings
---common.py #Common settings for develpment and production
---development.py
---production.py
---__init__.py
-static
...
I tried already to move them all to the same folder,
I did the following change in miApp.urls
path('', views.inicio, name='inicio'),
path('admin/', admin.site.urls),
path('cuentas/', include('apps.accounts.urls')),
path('participation/', include('apps.participation.urls')),
path('administracion/', include('apps.administration.urls')),
And also this, in the settings of common.py
DJANGO_APPS = ['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites'
]
THIRD_PARTIES = [# Django AllAuth
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.facebook',
'allauth.socialaccount.providers.google',
'allauth.socialaccount.providers.twitter',
# Django guardian
'guardian',
#Django meta
'meta',
# Django push notifications
'push_notifications',
]
MI_APP_APPS = [# MyVoto Instaled apps
'apps.accounts.apps.AccountsConfig',
'apps.participation.apps.ParticipationConfig',
'apps.administration.apps.AdministrationConfig']
INSTALLED_APPS = DJANGO_APPS + THIRD_PARTIES + MI_APP_APPS
I have the following config classes in apps.py
class AccountsConfig(AppConfig):
name = 'apps.accounts'
class AdministrationConfig(AppConfig):
name = 'apps.administration'
class ParticipationConfig(AppConfig):
name = 'apps.participation'
And I am getting the following error:
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x107afa488>
Traceback (most recent call last):
File "/Users/robertofernandez/PycharmProjects/miApp/venv/lib/python3.6/site-packages/django/apps/config.py", line 143, in create
app_module = import_module(app_name)
File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/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 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'accounts'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/robertofernandez/PycharmProjects/miApp/venv/lib/python3.6/site-packages/django/utils/autoreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "/Users/robertofernandez/PycharmProjects/miApp/venv/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 112, in inner_run
autoreload.raise_last_exception()
File "/Users/robertofernandez/PycharmProjects/miApp/venv/lib/python3.6/site-packages/django/utils/autoreload.py", line 248, in raise_last_exception
raise _exception[1]
File "/Users/robertofernandez/PycharmProjects/miApp/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 327, in execute
autoreload.check_errors(django.setup)()
File "/Users/robertofernandez/PycharmProjects/miApp/venv/lib/python3.6/site-packages/django/utils/autoreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "/Users/robertofernandez/PycharmProjects/miApp/venv/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Users/robertofernandez/PycharmProjects/miApp/venv/lib/python3.6/site-packages/django/apps/registry.py", line 89, in populate
app_config = AppConfig.create(entry)
File "/Users/robertofernandez/PycharmProjects/miApp/venv/lib/python3.6/site-packages/django/apps/config.py", line 147, in create
app_name, mod_path, cls_name,
django.core.exceptions.ImproperlyConfigured: Cannot import 'accounts'. Check that 'apps.accounts.apps.AccountsConfig.name' is correct.
I have the following in apps.accounts.apps.py
class AccountsConfig(AppConfig): name = 'accounts'