Intento publicar un proyecto de django en Heroku pero tengo problemas con los archivos estáticos. Esta es mi configuración:
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') STATIC_URL = '/static/' # Extra places for collectstatic to find static files. STATICFILES_DIRS = [ os.path.join(BASE_DIR, 'static'), ] STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'Pero Heroku regresa:
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/build_02a3e2abd7f176139303f077e32a2e9b/static' remote: remote: ! Error while running '$ python manage.py collectstatic --noinput'. remote: See traceback above for details. remote: remote: You may need to update application code to resolve this error. remote: Or, you can disable collectstatic for this application: remote: remote: $ heroku config:set DISABLE_COLLECTSTATIC=1 remote: remote: https://devcenter.heroku.com/articles/django-assets remote: ! Push rejected, failed to compile Python app. remote: remote: ! Push failed remote: Verifying deploy...No tengo solución, entiendo el problema pero no sé cómo solucionarlo :( La estructura de mi proyecto se ve así:
├── Procfile ├── manage.py ├── my_project │ ├── __init__.py │ ├── settings │ │ ├── __init__.py │ │ ├── base.py │ │ ├── dev.py │ │ └── prod.py │ ├── urls.py │ └── wsgi.py ├── requirements.txt ├── runtime.txt ├── static └── staticfilesLa documentación sobre Django o Heroku no explica cuándo la configuración se divide por entorno :(
He solucionado mi problema simplemente configurando:
MEDIA_ROOT = 'media' STATIC_ROOT = 'static'