From 9eecb9169566db263e243e4522b08ea1403ee95f Mon Sep 17 00:00:00 2001 From: Vajrasky Kok Date: Sat, 19 Oct 2013 20:40:12 +0800 Subject: 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. --- docs/ref/contrib/staticfiles.txt | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'docs/ref/contrib') diff --git a/docs/ref/contrib/staticfiles.txt b/docs/ref/contrib/staticfiles.txt index 1a9fd25ca9..c65533fa0f 100644 --- a/docs/ref/contrib/staticfiles.txt +++ b/docs/ref/contrib/staticfiles.txt @@ -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 ` 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 ======== -- cgit v1.3