Django: Ticket #10896: UrlField cannot be used with relative URLshttps://code.djangoproject.com/ticket/10896
<p>
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.
</p>
<p>
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.
</p>
<p>
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 <a class="ext-link" href="http://"><span class="icon">​</span>http://</a> is relative.
</p>
en-usDjangohttps://www.djangoproject.com/s/img/site/hdr_logo.gifhttps://code.djangoproject.com/ticket/10896
Trac 1.0.7notanumberWed, 22 Apr 2009 20:54:00 GMTneeds_docs, needs_tests, needs_better_patch sethttps://code.djangoproject.com/ticket/10896#comment:1
https://code.djangoproject.com/ticket/10896#comment:1
<ul>
<li><strong>needs_docs</strong>
unset
</li>
<li><strong>needs_tests</strong>
unset
</li>
<li><strong>needs_better_patch</strong>
unset
</li>
</ul>
TicketdcThu, 23 Apr 2009 18:54:37 GMThttps://code.djangoproject.com/ticket/10896#comment:2
https://code.djangoproject.com/ticket/10896#comment:2
<p>
That behaviour was specially added in <a class="closed ticket" href="https://code.djangoproject.com/ticket/5331" title="URLField should add http:// if no scheme given (closed: fixed)">#5331</a> by the core developer so this ticket looks like 'wontfix'.
</p>
TicketmtredinnickSun, 26 Apr 2009 20:08:22 GMTstatus changed; resolution sethttps://code.djangoproject.com/ticket/10896#comment:3
https://code.djangoproject.com/ticket/10896#comment:3
<ul>
<li><strong>status</strong>
changed from <em>new</em> to <em>closed</em>
</li>
<li><strong>resolution</strong>
set to <em>wontfix</em>
</li>
</ul>
<p>
Suspect the solution here is to use a different field. Right now, we require absolute URLs and you want a <tt>RelativeURLField</tt>, which carries a whole bunch of bonus assumptions or requirements (e.g. relative to <em>what</em>?) that make it not usable in all the same places that <tt>URLField</tt> is.
</p>
<p>
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.
</p>
<p>
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.
</p>
Ticket