當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。