Search code examples
djangocollectstatic

Django collectstatic : change source of static files


I have a Django app, with a folder named static. When the app is deployed, python manage.py collecstatic is automatically ran and this folder is copied into public/static and everything works perfectly.
However, I want to run a gulp task before, that minifies my files and copy them into a folder named dist.
The question is : is there a way to specify to collecstatic command, in which folder are the static files ?


Solution

  • You should just configure the STATICFILES_DIRS: https://docs.djangoproject.com/en/1.9/ref/settings/#staticfiles-dirs

    For further reading: https://lincolnloop.com/blog/integrating-front-end-tools-your-django-project/

    Btw I would consider separating the front-end code and the backend code and serve the frontend from a CDN