Django Staticfiles nicht auf Heroku (mit Whitenoise) gefunden
Diese Frage scheint mehrmals gestellt worden zu sein, aber ich kann sie nicht beheben.
Ich habe eine Django-App für die Produktion mit @ bereitgestellDEBUG = False
. Ich setze meinallowed_host
. Ich benutzte{% load static from staticfiles %}
, um statische Dateien zu laden. Ich schreibe genau die von Heroku vorgeschlagenen Einstellungen:
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
STATIC_ROOT = os.path.join(PROJECT_ROOT, 'staticfiles')
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(PROJECT_ROOT, 'static'),
)
STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
ABER ich habe einen Fehler 500 bekommen. Und diesen Traceback bekommen (per Mail)
...
`cache_name = self.clean_name(self.hashed_name(name))
File "/app/.heroku/python/lib/python3.5/site- packages/django/contrib/staticfiles/storage.py", line 94, in hashed_name (clean_name, self))
...
ValueError: The file ‘app/css/font.css’ could not be found with <whitenoise.django.GzipManifestStaticFilesStorage object at 0x7febf600a7f0>.`
Wenn ich renneheroku run python manage.py collectstatic --noinput
Alles scheint in Ordnung:
276 static files copied to '/app/annuaire/staticfiles', 276 post-processed.
Hat jemand eine Idee, mir zu helfen, bitte?
Vielen Dan
EDIT:
annuaire
|-- /annuaire
|-- -- /settings.py
|-- /app
|-- -- /static/...`
wsgi.py
from django.core.wsgi import get_wsgi_application
from whitenoise.django import DjangoWhiteNoise
application = get_wsgi_application()
application = DjangoWhiteNoise(application)