当前位置: 首页>>代码示例>>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;未经允许,请勿转载。