I am using storages and s3boto to serve static content and media. Here are
the related settings values:
INSTALLED_APPS = (
...
'storages',
...
'django.contrib.staticfiles',
...
)
AWS_STORAGE_BUCKET_NAME = "bucketname"
MEDIA_ROOT = ''
MEDIA_URL = "//%s.s3.amazonaws.com/" % AWS_STORAGE_BUCKET_NAME
STATICFILES_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
STATIC_ROOT = os.path.join(VAR_ROOT, 'static')
STATIC_URL = 'http://%s.s3.amazonaws.com/' % AWS_STORAGE_BUCKET_NAME
When I ran "collectstatic --clear," the media files and the static files
were deleted, but I would expect that only static files would effected by
this call.
Ideally this command would only effect static files, but at the very least
there would be a warning in the documentation that this deletes all
content in the static folder.
--
Ticket URL: <https://code.djangoproject.com/ticket/22891>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* component: contrib.staticfiles => Documentation
* needs_tests: => 0
* needs_docs: => 0
* type: Uncategorized => Cleanup/optimization
* stage: Unreviewed => Accepted
Comment:
In the `FileSystemStorage` case, `MEDIA_ROOT` and `STATIC_ROOT` cannot be
the same, so you aren't likely to run into this issue. I guess django-
storage works a bit differently. But yes, it's not intended that you
storage media files and static files in the same location. In fact,
[https://docs.djangoproject.com/en/dev/ref/settings/#media-url we
document] "MEDIA_URL and STATIC_URL must have different values." If you'd
like to write a patch, I'll be happy to review and commit it.
--
Ticket URL: <https://code.djangoproject.com/ticket/22891#comment:1>
* easy: 0 => 1
Comment:
To make it clear, this is the correct behaviour. Django can't tell whether
a particular file is a static file or not just by inspecting it.
Even if it removed only those that matched static files in the various
applications, that would neither guarantee complete removal nor
inadvertent removal, because applications' static files can change with
each version, or there may be static files left behind by an application
that's no longer installed.
The only safe thing to do is to clear the entire directory.
--
Ticket URL: <https://code.djangoproject.com/ticket/22891#comment:2>
Comment (by anonymous):
EvilDMP, I think this makes sense. In that case I think all that needs to
be more explicit is the warning message -- "This will delete all files in
the static directory, including files that are not managed by
staticfiles."
--
Ticket URL: <https://code.djangoproject.com/ticket/22891#comment:3>
Comment (by allcaps):
collectstatic --clear prints:
{{{
You have requested to collect static files at the destination
location as specified in your settings:
/Users/allcaps/path/to/project/static
This will DELETE EXISTING FILES!
Are you sure you want to do this?
}}}
The patch changes:
{{{
This will DELETE EXISTING FILES!
Are you sure you want to do this?
}}}
into:
{{{
'This will DELETE ALL FILES in the STATIC_ROOT directory!'
Are you sure you want to do this?
}}}
I'm not a fan of mentioning the unmanaged files.
--
Ticket URL: <https://code.djangoproject.com/ticket/22891#comment:4>
* cc: allcaps (added)
* has_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/22891#comment:5>
Comment (by timo):
I'm going to go with "This will DELETE ALL FILES in this location!" If a
custom storage is in use, the location might not be controlled by
`STATIC_ROOT`.
--
Ticket URL: <https://code.djangoproject.com/ticket/22891#comment:6>
* status: new => closed
* resolution: => fixed
Comment:
In [changeset:"faacc54ac8601e8bdbfdc8651d68267d570a9c4b"]:
{{{
#!CommitTicketReference repository=""
revision="faacc54ac8601e8bdbfdc8651d68267d570a9c4b"
Fixed #22891 -- Clarified that collecstatic --clear with delete all files
in the storage location.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/22891#comment:7>