Code

Opened 5 years ago

Closed 5 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: UI/UX:

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.

Attachments (0)

Change History (3)

comment:1 Changed 5 years ago by notanumber

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 5 years ago by dc

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

comment:3 Changed 5 years ago by mtredinnick

  • Resolution set to wontfix
  • Status changed from new to closed

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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.