Update staticfiles

Just looking for a confirmation here.

I have a website in a prod phase and need to update the css (sass). Just want to be sure that collectstatic will look only at the modified files with their timestamp, and not the whole thing (css, img, media) as it did once when I probably forgot to activate the virtual env

Thank you for your feedback.

Yes, as documented at The staticfiles app | Django documentation | Django.

However, keep in mind that depending upon your deployment process, the dates for all files might be changed to the date of the deployment, leading to all files being collected.

Thank you for confirming it. I’ll check that timestamp then before processing.

It didn’t work the way I thought. After running a collectstatic, I ended up with a recursive additional staticfiles folder, inside the previous one, with the same files in it than in its parent folder.

Examine “STATIC_ROOT” and/or “STATICFILES_DIRS” in settings.py, how have you configured them?

Hello, yes I did. As per below :

STATIC_URL = "/static/"
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles/')
    BASE_DIR, 'static',

See any mistake in there ?


It’s basically configured the same way in my settings.py although I defined STATICFILES_DIRS the old way:
STATICFILES_DIRS = (os.path.join(BASE_DIR, 'static/'),)
It probably shouldn’t make any difference though.

You could probably try removing (or commenting out) this STATICFILES_DIRS option entirely, and see if it makes a difference.

Didn’t change anything.

I forgot one detail, don’t know if it’s relevant or not, my static files, and the templates for that matter, are not located in the apps, but directly in the project/root folder. I don’t think it can have an influence on the collecstatic command though.

My staticfiles folder is at the root of the project too. You could probably delete the staticfiles folder and anything inside it. It doesn’t seem like normal behaviour when running that command.

Actually, this does appear to be a configuration issue.

You have:

The collectstatic is going to search each of those directories, in turn, and find the static files to copy. So what’s happening is that it’s finding the static directory inside BASE_DIR and the files in static directly causing two copies to be made.


Yes actually, good eye… I think it should look like this:

     BASE_DIR / "static",

Holy, didn’t know this could be of importance except in the case you want escape some characters. I tend to use single or double quotes a little randomly I must say.

Thanks for your input, will give it a try

It’s not the quotes that’s the issue here - it’s the separator between the two strings.

[ BASE_DIR , 'static' ] is a list of two strings.

[ BASE_DIR / 'static' ] or [ BASE_DIR / "static" ] is a list with one string, assuming BASE_DIR is a pathlib object.


Thanks a lot, just had it done, only the modified files have been, well, modified, others are untouched.