Django 1.8 - how static files can magically guess the name of a hashed file

I store my static files on Amazon S3 and I use Django caching, my storage class is as follows:

class MyStaticFilesStorage(ManifestFilesMixin, S3BotoStorage):
    ...

See: https://docs.djangoproject.com/en/1.8/ref/contrib/staticfiles/#manifeststaticfilesstorage

Once launched, manage.py collectstaticall static files are uploaded to S3 with a hash hash cache in the file name.

Everything works fine, but I don’t understand how to do it.

  • My folder staticis in .gitignore, so static files never reach my server.
  • staticfiles.jsoncreated by django is only saved on S3, so I went there and deleted it (so that I can see if it has an effect).
  • I can send ssh to the server and make sure that there is no file with the name on the server staticfiles.json, not static files.

But with all this, Django still generates the correct static URL on the server with the correct hash (for example: main.c076b26cc1a7.css).

How? How does django know a hash without mapping (staticfiles.json) and without a source file?

+4
source share
1 answer

I assume that Django first gets the staticfiles.json file from S3 and then reads the mapping from the file.

.gitignore, manage.py collectstatic, , Django , , , , git pull, manage.py collectsatic.

+1

Source: https://habr.com/ru/post/1606615/


All Articles