Opened 17 years ago
Closed 14 years ago
#5331 closed (fixed)
URLField should add http:// if no scheme given
Reported by: | Chris Beaven | Owned by: | nobody |
---|---|---|---|
Component: | Forms | Version: | dev |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The usual scheme for a URLField
is http://
. You're average user will often not enter the scheme of their URL so the clean method should just prepend 'http://'
if no scheme was given.
Attachments (2)
Change History (7)
by , 17 years ago
Attachment: | urlfield.patch added |
---|
comment:1 by , 17 years ago
Triage Stage: | Unreviewed → Design decision needed |
---|
comment:3 by , 17 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:4 by , 14 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
django.db.models.URLField doesn't have a custom 'formfield' method, and so by default it uses django.forms.CharField as its form field. And so django.forms.URLField never even gets used, so the patch submitted above is currently not having any effect (Django 1.3 alpha).
It needs a 'formfield' method adding to django.db.models.URLField...
#django/db/models/fields/__init__.py class URLField: #snip def formfield(self, **kwargs): if 'form_class' not in kwargs: kwargs['form_class'] = forms.URLField return super(URLField, self).formfield(**kwargs)
comment:5 by , 14 years ago
Has patch: | unset |
---|---|
Resolution: | → fixed |
Status: | reopened → closed |
Triage Stage: | Ready for checkin → Accepted |
@adamalton -- I don't know what code you're looking at, but URLField *does* have a custom formfield method, there is a unit test validating that http prefixing works as intended, and a quick test verifies that the field is working as intended.
Makes sense to me, but I'll pass it past the core developers.