我们从Python开源项目中,提取了以下33个代码示例,用于说明如何使用django.forms.SlugField()。
def __init__(self, *args, **kwargs): kwargs['max_length'] = kwargs.get('max_length', 50) # Set db_index=True unless it's been set manually. if 'db_index' not in kwargs: kwargs['db_index'] = True self.allow_unicode = kwargs.pop('allow_unicode', False) if self.allow_unicode: self.default_validators = [validators.validate_unicode_slug] super(SlugField, self).__init__(*args, **kwargs)
def deconstruct(self): name, path, args, kwargs = super(SlugField, self).deconstruct() if kwargs.get("max_length") == 50: del kwargs['max_length'] if self.db_index is False: kwargs['db_index'] = False else: del kwargs['db_index'] if self.allow_unicode is not False: kwargs['allow_unicode'] = self.allow_unicode return name, path, args, kwargs
def get_internal_type(self): return "SlugField"
def formfield(self, **kwargs): defaults = {'form_class': forms.SlugField, 'allow_unicode': self.allow_unicode} defaults.update(kwargs) return super(SlugField, self).formfield(**defaults)
def __init__(self, *args, **kwargs): super(SlugField, self).__init__(*args, **kwargs)
def test_should_slug_convert_string(): assert_conversion(forms.SlugField, graphene.String)
def __init__(self, *args, **kwargs): self.allow_unicode = kwargs.pop('allow_unicode', False) if self.allow_unicode: self.default_validators = [ validators.validate_unicode_slug, validate_slug_numbers ] super(forms.SlugField, self).__init__(*args, **kwargs)
def __init__(self, slug_source='name', *args, **kwargs): label = kwargs.pop('label', "Slug") help_text = kwargs.pop('help_text', "URL-friendly unique shorthand") super(SlugField, self).__init__(label=label, help_text=help_text, *args, **kwargs) self.widget.attrs['slug-source'] = slug_source
def __init__(self, *args, **kwargs): kwargs['max_length'] = kwargs.get('max_length', 50) # Set db_index=True unless it's been set manually. if 'db_index' not in kwargs: kwargs['db_index'] = True super(SlugField, self).__init__(*args, **kwargs)
def deconstruct(self): name, path, args, kwargs = super(SlugField, self).deconstruct() if kwargs.get("max_length", None) == 50: del kwargs['max_length'] if self.db_index is False: kwargs['db_index'] = False else: del kwargs['db_index'] return name, path, args, kwargs
def formfield(self, **kwargs): defaults = {'form_class': forms.SlugField} defaults.update(kwargs) return super(SlugField, self).formfield(**defaults)
def __init__(self, slug_source='name', *args, **kwargs): label = kwargs.pop('label', 'Slug') help_text = kwargs.pop( 'help_text', 'Friendly unique shorthand used for URL and config') super(SlugField, self).__init__(label=label, help_text=help_text, *args, **kwargs) self.widget.attrs['slug-source'] = slug_source