#25594: Difficult to customize model field default_validators and have them 
used on
both model and form fields
-------------------------------------+-------------------------------------
     Reporter:  marcinn              |                    Owner:  nobody
         Type:  New feature          |                   Status:  new
    Component:  Database layer       |                  Version:  master
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by timgraham):

 * needs_better_patch:   => 0
 * component:  Forms => Database layer (models, ORM)
 * needs_tests:   => 0
 * version:  1.8 => master
 * needs_docs:   => 0
 * type:  Bug => New feature
 * stage:  Unreviewed => Accepted


Comment:

 This problem exists for more than just `URLField` so I'm going to retitle
 the ticket to reflect that. Using the use case from #25593 of customizing
 a `URLValidator`'s accepted schemes, my idea would be to allow something
 like:

 `URLField(validators=[URLValidator(schemes=[])])`

 and have that validator be used in place of the default validator on both
 the model and form field. Thinking out loud: would it be acceptable to
 replace any `default_validators` with values from `validators` if the
 value from `validators` is a subclass of a value in `default_validators`?
 I guess for something like `RegexValidator` you may want to have multiple
 regular expressions so we probably need a different way to say "use this
 validator to replace the default validators". Maybe a `default_validators`
 argument to model fields? This change seems tricky and likely needs a
 discussion on the DevelopersMailingList to nail down the API details, but
 I agree it'd be a worthwhile improvement.

--
Ticket URL: <https://code.djangoproject.com/ticket/25594#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.40d0ac6710b2b0d432b53a72208b2caa%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to