Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django - app in subfolder

Tags:

python

django

I've created new django app in a subdirectory using the command:

python manage.py startapp appName subFolder/appName

but if I try to add this app to INSTALLED_APPS at the end of the list I see the following error:

ImportError: No module named appName

Does anyone know what I am doing wrong?

like image 770
pyt ho9 Avatar asked Aug 28 '26 19:08

pyt ho9


2 Answers

You need to include the subfolder when you add the app to INSTALLED_APPS, for example:

'subFolder.appName',

or

'subfolder.appName.apps.AppNameConfig',
like image 88
Alasdair Avatar answered Aug 31 '26 08:08

Alasdair


I tried different options but no one can solve that issue.

Finally, I found a solution.

Simply go to the subFolder/appName/apps.py file and

replace this line name = 'appname' with name = 'subfolder.appname'

And then you can simply add to the installed apps list in settings.py.

'subfolder.appname'
like image 26
Sumit Kumar Gupta Avatar answered Aug 31 '26 09:08

Sumit Kumar Gupta