Essex
Essex

Reputation: 6138

Django and Collectstatic Issue

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 ?

Upvotes: 2

Views: 44

Answers (1)

neverwalkaloner
neverwalkaloner

Reputation: 47364

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

Upvotes: 2

Related Questions