Django collectstatic --no input Yes instead of no
Asked Answered
T

2

9

I am using Django3 and i have currently the following command in my makefile for "Build"

python3 manage.py collectstatic 

to automate my buildprocess with a pipeline i would like to get rid of the prompt that asks

You have requested to collect static files at the destination location as specified in your settings:

URL

This will overwrite existing files! Are you sure you want to do this?

Type 'yes' to continue, or 'no' to cancel

i found that out that i can add "--no-input" for the collectstatic at the end, but this will answer "no" in this case. Is there a way how i could say the script to answer "Yes" by default instead?

Theologue answered 17/3, 2021 at 19:4 Comment(0)
B
15

As mentioned in Django docs:

On subsequent collectstatic runs (if STATIC_ROOT isn’t empty), files are copied only if they have a modified timestamp greater than the timestamp of the file in STATIC_ROOT.

So django by default overwrites your modified files on collectstatic command, --noinput flag means it will not ask for your permission.

Bloodshot answered 17/3, 2021 at 19:28 Comment(1)
This doesn't answer the question. What if the timestamp is less than the timestamp of the file in STATIC_ROOT but you wish to force a yes response with no-input?Whaling
M
0
yes yes | python3 manage.py collectstatic 

Works :)

Midwife answered 19/8 at 13:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.