2

I'm trying to deploy my Django web Application (2.0.1) thanks to Nginx and I'm getting an issue.

I configured the new Ubuntu server, add my Django Project and I downloaded nginx.

My Django project looks like :

Mysite
├── App1
├── App2
├── App3
├── lib
    ├── Global_variables.py
├── Mysite
    ├── settings.py

I have to make collectstatic with nginx, so I execute this command :

python manage.py collectstatic

But into my settings.py file, I have :

#from django.conf import global_settings
import os, datetime
import lib.Global_variables

And this issue :

File "/var/www/Mysite/Mysite/settings.py", line 16, in <module>
    import lib.Global_variables
ImportError: No module named lib.Global_variables

However my import seems to be right. Any idea ?

Essex
  • 6,042
  • 11
  • 67
  • 139
  • 1
    Hi! Try to add `__init__.py` to the lib folder. This will convert lib to python package. – neverwalkaloner Apr 23 '18 at 14:52
  • 1
    It seems to work but I have some issues with modules installed into `INSTALLED_APPS`. I think you could add your message as an answer and I will validate it ;) – Essex Apr 23 '18 at 14:57

1 Answers1

2

To make directory a python package you need to add inside this directory __init__.py file. From the docs:

The init.py files are required to make Python treat the directories as containing packages; this is done to prevent directories with a common name, such as string, from unintentionally hiding valid modules that occur later on the module search path

neverwalkaloner
  • 46,181
  • 7
  • 92
  • 100