Re: [Django] #36054: Add schemes parameter to URLField for custom URL scheme validation

6 views
Skip to first unread message

Django

unread,
Jan 2, 2025, 12:54:13 AM1/2/25
to django-...@googlegroups.com
#36054: Add schemes parameter to URLField for custom URL scheme validation
-------------------------------------+-------------------------------------
Reporter: Youngkwang Yang | Owner:
| Youngkwang Yang
Type: New feature | Status: assigned
Component: Forms | Version: dev
Severity: Normal | Resolution:
Keywords: URLField, | Triage Stage:
forms.URLField, schemes, URL | Unreviewed
validation, custom schemes |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Youngkwang Yang):

* owner: (none) => Youngkwang Yang
* status: new => assigned

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

Django

unread,
Jan 2, 2025, 3:31:31 AM1/2/25
to django-...@googlegroups.com
#36054: Add schemes parameter to URLField for custom URL scheme validation
-------------------------------------+-------------------------------------
Reporter: Youngkwang Yang | Owner:
| Youngkwang Yang
Type: New feature | Status: closed
Component: Forms | Version: dev
Severity: Normal | Resolution: wontfix
Keywords: URLField, | Triage Stage:
forms.URLField, schemes, URL | Unreviewed
validation, custom schemes |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):

* resolution: => wontfix
* status: assigned => closed

Comment:

Hi Youngkwang Yang, thank you for this suggestion

You can add a validator to a field, so this should already be achievable
with something like:
{{{
secure_url =
models.URLField(validators=[validators.URLValidator(schemes=["https"]))
}}}

In general, as you are requesting a new feature for Django, the
recommended path forward is to first propose and discuss the idea with the
community and gain consensus. To do that, please consider starting a new
conversation on the [https://forum.djangoproject.com/c/internals/5 Django
Forum], where you'll reach a broader audience and receive additional
feedback.

I'll close the ticket for now, but if the community agrees with the
proposal, please return to this ticket and reference the forum discussion
so we can re-open it. For more information, please refer to
[https://docs.djangoproject.com/en/stable/internals/contributing/bugs-and-
features/#requesting-features the documented guidelines for requesting
features].
--
Ticket URL: <https://code.djangoproject.com/ticket/36054#comment:3>

Django

unread,
Jan 2, 2025, 4:19:24 AM1/2/25
to django-...@googlegroups.com
#36054: Add schemes parameter to URLField for custom URL scheme validation
-------------------------------------+-------------------------------------
Reporter: Youngkwang Yang | Owner:
| Youngkwang Yang
Type: New feature | Status: closed
Component: Forms | Version: dev
Severity: Normal | Resolution: wontfix
Keywords: URLField, | Triage Stage:
forms.URLField, schemes, URL | Unreviewed
validation, custom schemes |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Youngkwang Yang):

thank you for your response.

The method you suggested is effective for restricting existing URL schemes
to https, but it makes extending schemes like custom-scheme, deeplink, or
mailto:// challenging. This is because the validators passed as arguments
are combined with the existing default_validators, causing URLValidator
validation to run twice.

thank you for the guidance! I will start a discussion about this feature
on the Django Forum.
--
Ticket URL: <https://code.djangoproject.com/ticket/36054#comment:4>

Django

unread,
Jan 2, 2025, 6:33:10 AM1/2/25
to django-...@googlegroups.com
#36054: Add schemes parameter to URLField for custom URL scheme validation
-------------------------------------+-------------------------------------
Reporter: Youngkwang Yang | Owner:
| Youngkwang Yang
Type: New feature | Status: closed
Component: Forms | Version: dev
Severity: Normal | Resolution: wontfix
Keywords: URLField, | Triage Stage:
forms.URLField, schemes, URL | Unreviewed
validation, custom schemes |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Tim Graham):

See #25594: "Difficult to customize model field default_validators and
have them used on both model and form fields".
--
Ticket URL: <https://code.djangoproject.com/ticket/36054#comment:5>
Reply all
Reply to author
Forward
0 new messages