当前位置: 首页>>代码示例>>Python>>正文


Python forms.FilePathField方法代码示例

本文整理汇总了Python中django.forms.FilePathField方法的典型用法代码示例。如果您正苦于以下问题:Python forms.FilePathField方法的具体用法?Python forms.FilePathField怎么用?Python forms.FilePathField使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在django.forms的用法示例。


在下文中一共展示了forms.FilePathField方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_recursive

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import FilePathField [as 别名]
def test_recursive(self):
        f = FilePathField(path=self.path, recursive=True, match=r'^.*?\.py$')
        expected = [
            ('/filepathfield_test_dir/__init__.py', '__init__.py'),
            ('/filepathfield_test_dir/a.py', 'a.py'),
            ('/filepathfield_test_dir/ab.py', 'ab.py'),
            ('/filepathfield_test_dir/b.py', 'b.py'),
            ('/filepathfield_test_dir/c/__init__.py', 'c/__init__.py'),
            ('/filepathfield_test_dir/c/d.py', 'c/d.py'),
            ('/filepathfield_test_dir/c/e.py', 'c/e.py'),
            ('/filepathfield_test_dir/c/f/__init__.py', 'c/f/__init__.py'),
            ('/filepathfield_test_dir/c/f/g.py', 'c/f/g.py'),
            ('/filepathfield_test_dir/h/__init__.py', 'h/__init__.py'),
            ('/filepathfield_test_dir/j/__init__.py', 'j/__init__.py'),

        ]
        self.assertChoices(f, expected) 
开发者ID:nesdis,项目名称:djongo,代码行数:19,代码来源:test_filepathfield.py

示例2: __init__

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import FilePathField [as 别名]
def __init__(self, path, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.fields['original'] = forms.FilePathField(
            path=path, recursive=True)
        self.fields['preview'] = forms.FilePathField(
            path=path, recursive=True, required=False) 
开发者ID:ideascube,项目名称:ideascube,代码行数:8,代码来源:forms.py

示例3: __init__

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import FilePathField [as 别名]
def __init__(self, verbose_name=None, name=None, path='', match=None,
                 recursive=False, allow_files=True, allow_folders=False, **kwargs):
        self.path, self.match, self.recursive = path, match, recursive
        self.allow_files, self.allow_folders = allow_files, allow_folders
        kwargs['max_length'] = kwargs.get('max_length', 100)
        super(FilePathField, self).__init__(verbose_name, name, **kwargs) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:8,代码来源:__init__.py

示例4: check

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import FilePathField [as 别名]
def check(self, **kwargs):
        errors = super(FilePathField, self).check(**kwargs)
        errors.extend(self._check_allowing_files_or_folders(**kwargs))
        return errors 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:6,代码来源:__init__.py

示例5: deconstruct

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import FilePathField [as 别名]
def deconstruct(self):
        name, path, args, kwargs = super(FilePathField, self).deconstruct()
        if self.path != '':
            kwargs['path'] = self.path
        if self.match is not None:
            kwargs['match'] = self.match
        if self.recursive is not False:
            kwargs['recursive'] = self.recursive
        if self.allow_files is not True:
            kwargs['allow_files'] = self.allow_files
        if self.allow_folders is not False:
            kwargs['allow_folders'] = self.allow_folders
        if kwargs.get("max_length", None) == 100:
            del kwargs["max_length"]
        return name, path, args, kwargs 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:17,代码来源:__init__.py

示例6: get_prep_value

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import FilePathField [as 别名]
def get_prep_value(self, value):
        value = super(FilePathField, self).get_prep_value(value)
        if value is None:
            return None
        return six.text_type(value) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:7,代码来源:__init__.py

示例7: formfield

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import FilePathField [as 别名]
def formfield(self, **kwargs):
        defaults = {
            'path': self.path,
            'match': self.match,
            'recursive': self.recursive,
            'form_class': forms.FilePathField,
            'allow_files': self.allow_files,
            'allow_folders': self.allow_folders,
        }
        defaults.update(kwargs)
        return super(FilePathField, self).formfield(**defaults) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:13,代码来源:__init__.py

示例8: formfield

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import FilePathField [as 别名]
def formfield(self, **kwargs):
        defaults = {
            'path': self.path,
            'match': self.match,
            'recursive': self.recursive,
            'form_class': forms.FilePathField,
            'allow_files': self.allow_files,
            'allow_folders': self.allow_folders,
        }
        defaults.update(kwargs)
        return super().formfield(**defaults) 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:13,代码来源:__init__.py

示例9: get_internal_type

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import FilePathField [as 别名]
def get_internal_type(self):
        return "FilePathField" 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:4,代码来源:__init__.py

示例10: formfield

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import FilePathField [as 别名]
def formfield(self, **kwargs):
        return super().formfield(**{
            'path': self.path,
            'match': self.match,
            'recursive': self.recursive,
            'form_class': forms.FilePathField,
            'allow_files': self.allow_files,
            'allow_folders': self.allow_folders,
            **kwargs,
        }) 
开发者ID:PacktPublishing,项目名称:Hands-On-Application-Development-with-PyCharm,代码行数:12,代码来源:__init__.py

示例11: deconstruct

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import FilePathField [as 别名]
def deconstruct(self):
        name, path, args, kwargs = super(FilePathField, self).deconstruct()
        if self.path != '':
            kwargs['path'] = self.path
        if self.match is not None:
            kwargs['match'] = self.match
        if self.recursive is not False:
            kwargs['recursive'] = self.recursive
        if self.allow_files is not True:
            kwargs['allow_files'] = self.allow_files
        if self.allow_folders is not False:
            kwargs['allow_folders'] = self.allow_folders
        if kwargs.get("max_length") == 100:
            del kwargs["max_length"]
        return name, path, args, kwargs 
开发者ID:Yeah-Kun,项目名称:python,代码行数:17,代码来源:__init__.py

示例12: __init__

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import FilePathField [as 别名]
def __init__(self, path, match=None, recursive=False, allow_files=True,
                 allow_folders=False, required=None, **kwargs):
        # Defer to Django's FilePathField implementation to get the
        # valid set of choices.
        field = DjangoFilePathField(
            path, match=match, recursive=recursive, allow_files=allow_files,
            allow_folders=allow_folders, required=required
        )
        kwargs['choices'] = field.choices
        super(FilePathField, self).__init__(**kwargs)


# File types... 
开发者ID:BeanWei,项目名称:Dailyfresh-B2C,代码行数:15,代码来源:fields.py


注:本文中的django.forms.FilePathField方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。