I agree with Tim completely.
I do see one thing that could help here: Add a check that STATIC_ROOT is not a
subfolder of any app. This check cannot be really reliable (that is, a
particularly careless and unlucky user could set things up so that their
STATIC_ROOT is in an app but the check will not notice it -- a couple of soft-
links will do the trick), but a blunder as described here (STATIC_ROOT is
simply the same as the static folder of an app) can be identified and warned
against.
I don't think such a check belongs in Django, given its inherent unreliability
and the low probabiity of such errors (this is the first time I've heard of
one), but with 1.7, you could just add it yourself; you can publish it and it
can live as a 3rd-party library until it proves me wrong by gaining wide-
spread use.
Shai.
> >> deployment; it is *not* a place to store your static files
> >> permanently."
> >
> > This makes it necessary that a STATIC_ROOT location is fixed for Django
> > itself but it then adds a friction for other apps running with it. We
> > should minimize the requirement that people learn certain laws before
> > using Django because it is possible that they don't and ideally we
> > should have mechanisms to figure out that they are not and then alert
> > them, I am not sure if these alerts are there.
> >
> > Thanks,
> > Prathik
> >
> > On Wednesday, October 29, 2014 10:51:13 PM UTC+5:30, Tim Graham wrote:
> >> "we make it clear that it will delete the existing files and get a
> >> prompt from them"
> >>
> >> Doesn't this already happen per the commits I linked in the ticket?
> >>
> >> "Unless the design decision of Django is that files directly written to
> >> STATIC_ROOT shouldn't be preserved,"
> >>
> >> Yes, as the documentation for STATIC_ROOT says, "This should be an
> >> (initially empty) destination directory for collecting your static files
> >> from their permanent locations into one directory for ease of
> >> deployment; it is *not* a place to store your static files
> >>>>>> - We want the files in STATIC_ROOT to be replaced even if the one
> >>>>>> there is newer. Currently I don't see a way to do this apart from
> >>>>>> using --clear which deletes the entire directory, where other
> >>>>>> apps could be writing too. We could implement overwrite where it
> >>>>>> does a filecmp and then overwrites.
> >>>>>> - The clear method deletes the files irrespective of where they
> >>>>>> are, an accident could mean that data could be lost for ever. In
> >>>>>> one instance our production box had STATIC_ROOT point to a
> >>>>>> folder in the app accidentally, then collectstatic was not
> >>>>>> fetching a file from a sub app which was linked to the main
> >>>>>> project, we ran collectstatic --clear and it deleted the static
> >>>>>> folder of the main project which had some base css/js files.
> >>>>>> This could have brought down production for a while if not for a
> >>>>>> caching mechanism.
> >>>>>> - Django should be able to run in a safe mode where no unintended
> >>>>>> side-effects should happen.
> >>>>>>
> >>>>>> What are your thoughts on this?
> >>>>>
> >>>>> <
https://groups.google.com/d/msgid/django-developers/e16d9821-95ca-4
> >>>>> 3c8-930b-3e05f3a447d0%
40googlegroups.com?utm_medium=email&utm_source=
> >>>>> footer> .