forms.RegexField

class RegexField(**kwargs) [source]

  • Default widget: TextInput
  • Empty value: '' (an empty string)
  • Normalizes to: A Unicode object.
  • Validates that the given value matches against a certain regular expression.
  • Error message keys: required, invalid

Takes one required argument:

regex

A regular expression specified either as a string or a compiled regular expression object.

Also takes max_length, min_length, and strip, which work just as they do for CharField.

strip
New in Django 1.9.

Defaults to False. If enabled, stripping will be applied before the regex validation.

doc_Django
2016-10-09 18:37:05
Comments
Leave a Comment

Please login to continue.