0
votes

I wanted to change directory of where are my apps. my django project is in this directory:

'/home/user/djcode/dev/myproject'

When I started this project, my apps where in this directory:

'/home/user/djcode/dev/myproject'

Aslo in settings.py I added this line (in INSTALLED_APPS):

'finance',

And everything worked.

Later I wanted to change my apps directory so I moved my apps to:

'/home/user/djcode/dev/myproject/myproject/apps' 

And in settings.py I changed 'finance' into this line (in INSTALLED_APPS):

'myproject.apps.finance'

And when I ran python manage.py runserver command, I got this error:

Error: No module named apps.finance

I know I can just add path directly to where my apps are, so I think it would solve it. But isn't there a way to specify this path without adding it in .pth file?

What I mean is if python knows /home/user/djcode/dev/myproject path why it does not find /home/user/djcode/dev/myproject/myproject/apps?

Maybe I just wrongly specified in installed_apps?

Also I use virtualenv with this project, so django is installed using virtualenv. But I think it's not related, because it finds where my project is, but can't find apps if they are in lower directory lelvels.

1
Or it could be a circular import? Or you might not have a __init__.py in the apps` directory - aychedee
Oh.. How could I forgot about __init__.py.. Thats it. Thank you very much. Now it works:) - Andrius
@aychedee You can post it as answer and I will accept it if you want. - Andrius

1 Answers

2
votes

Or it could be a circular import? Or you might not have a init.py in the apps` directory?