Search code examples
pythoncssdjangodebiandeb

Can Django collectstatic overwrite old files?


In my deb postinst file:

PYTHON=/usr/bin/python
PYTHON_VERSION=`$PYTHON -c 'import sys; print sys.version[:3]'`
SITE_PACKAGES=/opt/pkgs/mypackage/lib/python$PYTHON_VERSION/site-packages
export PYTHONPATH=$SITE_PACKAGES
echo "collect static files"
$PYTHON manage.py collectstatic --noinput 

When I run 'dpkg -i mypackage.deb' to install the package, no problem.

When I run 'dpkg -i mypackage.deb' to re-install the package, old css files unchanged.

When I changed '$PYTHON manage.py collectstatic --noinput ' to '$PYTHON manage.py collectstatic --noinput -c' and run 'dpkg -i mypackage.deb' to re-install the package, the error is following: OSError: [Errno 2] No such file or directory: '/opt/pkgs/myporject/static'

Any idea?

Can Django collectstatic overwrite old files?


Solution

  • (Added here, maybe someone will have same problems with mine.) Yes.

    The timestamp of css files in /opt/pkgs/mypropject/lib/python2.7/site-packages/mypropject-py2.7.egg/myapp/static/css (directory A) is the time when package building finished, not the time when css files installed.

    But the timestamp of css files in /opt/pkgs/myporject/static (directory B) is the time of installation.

    That is why collectstatic sometimes cannot overwrite my old css files (cannot copy some css files from directory A to directory B).