當前位置: 首頁>>代碼示例>>Python>>正文


Python storage.default_storage方法代碼示例

本文整理匯總了Python中django.core.files.storage.default_storage方法的典型用法代碼示例。如果您正苦於以下問題:Python storage.default_storage方法的具體用法?Python storage.default_storage怎麽用?Python storage.default_storage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在django.core.files.storage的用法示例。


在下文中一共展示了storage.default_storage方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: ready

# 需要導入模塊: from django.core.files import storage [as 別名]
# 或者: from django.core.files.storage import default_storage [as 別名]
def ready(self):
        from django.core.files.storage import default_storage
        from storages.backends.s3boto3 import S3Boto3Storage
        from django import forms

        from .forms import S3FileInputMixin

        if isinstance(default_storage, S3Boto3Storage) and \
                S3FileInputMixin not in forms.ClearableFileInput.__bases__:
            forms.ClearableFileInput.__bases__ = \
                (S3FileInputMixin,) + forms.ClearableFileInput.__bases__

        elif S3FileInputMixin in forms.ClearableFileInput.__bases__:
            forms.ClearableFileInput.__bases__ = tuple(
                cls for cls in forms.ClearableFileInput.__bases__
                if cls is not S3FileInputMixin
            )

        checks.register(storage_check, checks.Tags.security, deploy=True) 
開發者ID:codingjoe,項目名稱:django-s3file,代碼行數:21,代碼來源:apps.py

示例2: __init__

# 需要導入模塊: from django.core.files import storage [as 別名]
# 或者: from django.core.files.storage import default_storage [as 別名]
def __init__(self, verbose_name=None, name=None, upload_to='', storage=None, **kwargs):
        self._primary_key_set_explicitly = 'primary_key' in kwargs
        self._unique_set_explicitly = 'unique' in kwargs

        self.storage = storage or default_storage
        self.upload_to = upload_to
        if callable(upload_to):
            self.generate_filename = upload_to

        kwargs['max_length'] = kwargs.get('max_length', 100)
        super(FileField, self).__init__(verbose_name, name, **kwargs) 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:13,代碼來源:files.py

示例3: deconstruct

# 需要導入模塊: from django.core.files import storage [as 別名]
# 或者: from django.core.files.storage import default_storage [as 別名]
def deconstruct(self):
        name, path, args, kwargs = super(FileField, self).deconstruct()
        if kwargs.get("max_length", None) == 100:
            del kwargs["max_length"]
        kwargs['upload_to'] = self.upload_to
        if self.storage is not default_storage:
            kwargs['storage'] = self.storage
        return name, path, args, kwargs 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:10,代碼來源:files.py

示例4: __init__

# 需要導入模塊: from django.core.files import storage [as 別名]
# 或者: from django.core.files.storage import default_storage [as 別名]
def __init__(self, verbose_name=None, name=None, upload_to='', storage=None, **kwargs):
        self._primary_key_set_explicitly = 'primary_key' in kwargs

        self.storage = storage or default_storage
        self.upload_to = upload_to

        kwargs['max_length'] = kwargs.get('max_length', 100)
        super().__init__(verbose_name, name, **kwargs) 
開發者ID:reBiocoder,項目名稱:bioforum,代碼行數:10,代碼來源:files.py

示例5: deconstruct

# 需要導入模塊: from django.core.files import storage [as 別名]
# 或者: from django.core.files.storage import default_storage [as 別名]
def deconstruct(self):
        name, path, args, kwargs = super().deconstruct()
        if kwargs.get("max_length") == 100:
            del kwargs["max_length"]
        kwargs['upload_to'] = self.upload_to
        if self.storage is not default_storage:
            kwargs['storage'] = self.storage
        return name, path, args, kwargs 
開發者ID:reBiocoder,項目名稱:bioforum,代碼行數:10,代碼來源:files.py

示例6: is_in_bucket

# 需要導入模塊: from django.core.files import storage [as 別名]
# 或者: from django.core.files.storage import default_storage [as 別名]
def is_in_bucket(object_key):
    if not hasattr(default_storage, 'bucket'):
        return False
    else:    
        try:
            default_storage.bucket.Object(object_key).load()
            return True
        except S3_ClientError as e:
            if e.response['Error']['Code'] == "404":
                return False
            else:
                raise e 
開發者ID:OasisLMF,項目名稱:OasisPlatform,代碼行數:14,代碼來源:tasks.py

示例7: handle_upload

# 需要導入模塊: from django.core.files import storage [as 別名]
# 或者: from django.core.files.storage import default_storage [as 別名]
def handle_upload(self, request):
        """Handle file uploads from WYSIWYG."""
        if request.method != 'POST':
            raise Http404

        if request.is_ajax():
            try:
                filename = request.GET['quillUploadFile']
                data = request
                is_raw = True
            except KeyError:
                return HttpResponseBadRequest("Invalid file upload.")
        else:
            if len(request.FILES) != 1:
                return HttpResponseBadRequest("Can only upload 1 file at a time.")
            try:
                data = request.FILES['quillUploadFile']
                filename = data.name
                is_raw = False
            except KeyError:
                return HttpResponseBadRequest('Missing image `quillUploadFile`.')

        url = save_file(data, filename, is_raw, default_storage)
        response_data = {}
        response_data['url'] = url

        # Response content type needs to be text/html here or else
        # IE will try to download the file.
        return HttpResponse(json.dumps(response_data), content_type="text/html; charset=utf-8") 
開發者ID:coremke,項目名稱:django-quill,代碼行數:31,代碼來源:admin.py

示例8: __init__

# 需要導入模塊: from django.core.files import storage [as 別名]
# 或者: from django.core.files.storage import default_storage [as 別名]
def __init__(
        self, verbose_name=None, name=None, upload_to="", storage=None, **kwargs
    ):

        self.storage = storage or default_storage
        self.upload_to = upload_to

        super().__init__(verbose_name, name, **kwargs) 
開發者ID:SectorLabs,項目名稱:django-localized-fields,代碼行數:10,代碼來源:file_field.py

示例9: deconstruct

# 需要導入模塊: from django.core.files import storage [as 別名]
# 或者: from django.core.files.storage import default_storage [as 別名]
def deconstruct(self):
        name, path, args, kwargs = super().deconstruct()
        kwargs["upload_to"] = self.upload_to
        if self.storage is not default_storage:
            kwargs["storage"] = self.storage
        return name, path, args, kwargs 
開發者ID:SectorLabs,項目名稱:django-localized-fields,代碼行數:8,代碼來源:file_field.py

示例10: __init__

# 需要導入模塊: from django.core.files import storage [as 別名]
# 或者: from django.core.files.storage import default_storage [as 別名]
def __init__(self, verbose_name=None, name=None, upload_to='', storage=None, **kwargs):
        self._primary_key_set_explicitly = 'primary_key' in kwargs

        self.storage = storage or default_storage
        self.upload_to = upload_to

        kwargs.setdefault('max_length', 100)
        super().__init__(verbose_name, name, **kwargs) 
開發者ID:PacktPublishing,項目名稱:Hands-On-Application-Development-with-PyCharm,代碼行數:10,代碼來源:files.py

示例11: __init__

# 需要導入模塊: from django.core.files import storage [as 別名]
# 或者: from django.core.files.storage import default_storage [as 別名]
def __init__(self, verbose_name=None, name=None, upload_to='', storage=None, **kwargs):
        self._primary_key_set_explicitly = 'primary_key' in kwargs

        self.storage = storage or default_storage
        self.upload_to = upload_to

        kwargs['max_length'] = kwargs.get('max_length', 100)
        super(FileField, self).__init__(verbose_name, name, **kwargs) 
開發者ID:Yeah-Kun,項目名稱:python,代碼行數:10,代碼來源:files.py

示例12: deconstruct

# 需要導入模塊: from django.core.files import storage [as 別名]
# 或者: from django.core.files.storage import default_storage [as 別名]
def deconstruct(self):
        name, path, args, kwargs = super(FileField, self).deconstruct()
        if kwargs.get("max_length") == 100:
            del kwargs["max_length"]
        kwargs['upload_to'] = self.upload_to
        if self.storage is not default_storage:
            kwargs['storage'] = self.storage
        return name, path, args, kwargs 
開發者ID:Yeah-Kun,項目名稱:python,代碼行數:10,代碼來源:files.py

示例13: storage_check

# 需要導入模塊: from django.core.files import storage [as 別名]
# 或者: from django.core.files.storage import default_storage [as 別名]
def storage_check(app_configs, **kwargs):
    if isinstance(default_storage, FileSystemStorage):
        return [
            Error(
                'FileSystemStorage should not be used in a production environment.',
                hint='Please verify your DEFAULT_FILE_STORAGE setting.',
                id='s3file.E001',
            )
        ]
    return [] 
開發者ID:codingjoe,項目名稱:django-s3file,代碼行數:12,代碼來源:checks.py

示例14: get_storage

# 需要導入模塊: from django.core.files import storage [as 別名]
# 或者: from django.core.files.storage import default_storage [as 別名]
def get_storage():
    ''' return configured Storage '''
    return default_storage  # for default filesystem, (location=settings.MEDIA_ROOT) 
開發者ID:fridiculous,項目名稱:django-estimators,代碼行數:5,代碼來源:__init__.py

示例15: __init__

# 需要導入模塊: from django.core.files import storage [as 別名]
# 或者: from django.core.files.storage import default_storage [as 別名]
def __init__(self, verbose_name=None, name=None, upload_to='', storage=None, **kwargs):
        self._primary_key_set_explicitly = 'primary_key' in kwargs
        self._unique_set_explicitly = 'unique' in kwargs

        self.storage = storage or default_storage
        self.upload_to = upload_to

        kwargs['max_length'] = kwargs.get('max_length', 100)
        super(FileField, self).__init__(verbose_name, name, **kwargs) 
開發者ID:drexly,項目名稱:openhgsenti,代碼行數:11,代碼來源:files.py


注:本文中的django.core.files.storage.default_storage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。