Opened 15 years ago

Closed 15 years ago

#10896 closed (wontfix)

UrlField cannot be used with relative URLs

Reported by: notanumber Owned by: nobody
Component: Database layer (models, ORM) Version: 1.0
Severity: Keywords: url urlfield relative
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

models.URLField and forms.URLField cannot be used with relative URLs. This can be a problem when developing a site on domain and then deploying to another.

In our instance, we are trying to pull data from the "live" server to our "qa" servers, but of course, all the urls entered in URLFields are now broken because they still point to the live server.

Ultimately, URLField should support the use of relative URLs. Couldn't it be assumed and (possibly tested using verify_exists=True?) that a URL that does not contain http:// is relative.

Change History (3)

comment:1 by notanumber, 15 years ago

comment:2 by dc, 15 years ago

That behaviour was specially added in #5331 by the core developer so this ticket looks like 'wontfix'.

comment:3 by Malcolm Tredinnick, 15 years ago

Resolution: wontfix
Status: newclosed

Suspect the solution here is to use a different field. Right now, we require absolute URLs and you want a RelativeURLField, which carries a whole bunch of bonus assumptions or requirements (e.g. relative to what?) that make it not usable in all the same places that URLField is.

Since subclassing fields is fairly easily, encouraged and supported, let's not modify the existing field. Whether it's worth including the subclass in Django itself is a conversation to be had in the future after the subfield has existed for a while and adopted a massive userbase.

For now, though, closing as wontfix, since it appears to work as intended and as a feature change to an existing field, things get complicated fast. If all the problems are overcome when development is done, it's worth a discussion on django-dev, but that is also for the future.

Note: See TracTickets for help on using tickets.
Back to Top