1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #21219 -- Added a way to set different permission for static files.

Previously, when collecting static files, the files would receive permission
from FILE_UPLOAD_PERMISSIONS. Now, there's an option to give different
permission from uploaded files permission by subclassing any of the static
files storage classes and setting the file_permissions_mode parameter.

Thanks dblack at atlassian.com for the suggestion.
This commit is contained in:
Vajrasky Kok
2013-10-19 20:40:12 +08:00
committed by Tim Graham
parent c052699be3
commit 9eecb91695
7 changed files with 105 additions and 8 deletions

View File

@@ -32,8 +32,6 @@ following settings:
Management Commands
===================
.. highlight:: console
``django.contrib.staticfiles`` exposes three management commands.
collectstatic
@@ -61,6 +59,30 @@ receives all command line options of :djadmin:`collectstatic`. This is used
by the :class:`~django.contrib.staticfiles.storage.CachedStaticFilesStorage`
by default.
By default, collected files receive permissions from
:setting:`FILE_UPLOAD_PERMISSIONS`. If you would like different permissions for
these files, you can subclass either of the :ref:`static files storage
classes <staticfiles-storages>` and specify the ``file_permissions_mode``
parameter. For example::
from django.contrib.staticfiles import storage
class MyStaticFilesStorage(storage.StaticFilesStorage):
def __init__(self, *args, **kwargs):
kwargs['file_permissions_mode'] = 0o640
super(CustomStaticFilesStorage, self).__init__(*args, **kwargs)
Then set the :setting:`STATICFILES_STORAGE` setting to
``'path.to.MyStaticFilesStorage'``.
.. versionadded:: 1.7
The ability to override ``file_permissions_mode`` is new in Django 1.7.
Previously the file permissions always used
:setting:`FILE_UPLOAD_PERMISSIONS`.
.. highlight:: console
Some commonly used options are:
.. django-admin-option:: --noinput
@@ -174,6 +196,8 @@ Example usage::
django-admin.py runserver --insecure
.. _staticfiles-storages:
Storages
========