简体   繁体   中英

Django, gunicorn, nginx throws 504 Gateway Time-out: AttributeError: module 'static' has no attribute 'Cling'

yesterday I deployed a new version of my little website online and immediately received a 504 Gateway Time-out error.

After some digging in the log files I found the following error:


File "/home/dev/venuepark/ENV/lib/python3.6/site-packages/django/utils/autoreload.py", line 225, in wrapper
    fn(*args, **kwargs)
  File "/home/dev/venuepark/ENV/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 137, in inner_run
    handler = self.get_handler(*args, **options)
  File "/home/dev/venuepark/ENV/lib/python3.6/site-packages/django/contrib/staticfiles/management/commands/runserver.py", line 27, in get_handler
    handler = super().get_handler(*args, **options)
  File "/home/dev/venuepark/ENV/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 64, in get_handler
    return get_internal_wsgi_application()
  File "/home/dev/venuepark/ENV/lib/python3.6/site-packages/django/core/servers/basehttp.py", line 44, in get_internal_wsgi_application
    return import_string(app_path)
  File "/home/dev/venuepark/ENV/lib/python3.6/site-packages/django/utils/module_loading.py", line 17, in import_string
    module = import_module(module_path)
  File "/usr/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 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/dev/venuepark/venuepark/venuepark/wsgi.py", line 17, in <module>
    application = Cling(MediaCling(get_wsgi_application()))
  File "/home/dev/venuepark/ENV/lib/python3.6/site-packages/dj_static.py", line 97, in __init__
    super(MediaCling, self).__init__(application, base_dir=base_dir)
  File "/home/dev/venuepark/ENV/lib/python3.6/site-packages/dj_static.py", line 48, in __init__
    self.cling = static.Cling(base_dir)
AttributeError: module 'static' has no attribute 'Cling'

my wsgi.py:


import os

from django.core.wsgi import get_wsgi_application
from dj_static import Cling, MediaCling

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'venuepark.config.settings.production_settings')

application = Cling(MediaCling(get_wsgi_application()))

but dj-static is installed properly.

What could cause this problem? Thanks in advance

EDIT:

When I run the production settings locally everything is working fine. But when I try to run them on the production server (not with gunicorn but django's own runserver) I get the same error as I received in my gunicorn error logs (see error above).

I run the local settings as well and they also do raise the error above.

EDIT 2: I have created a new environment and re-installed the requirements files and the error still exists. AttributeError: module 'static' has no attribute 'Cling'

Check again your environment creation:

mkdir /tmp/djstatic && cd /tmp/djstatic
pipenv install django dj_static
pipenv run python -c "from dj_static import Cling"

It must work.

I suppose that you use pipenv for project environment creation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM