﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
32991	Change in behavior of FileField.url between versions 2.2.16 -> 3.2.5; returned 'relative' value contains leading slash	Elchin Mammadov	nobody	"Going through an upgrade of Django from version 2.2.16 to 3.2.5, believe I have found a regression in FileField.url

I have searched all the release notes between these two versions for any mentions of ""url"" but didn't find changes being mentioned to this behavior. Some of the recent release notes for Django 2.2 (2.2.21 and 2.2.23)  mention changes to FileField, maybe this is when the regression was introduced. 

Details of the issue:
Using the same model FileField definition and settings in both versions.

In 2.2.16 FileField.url returns a relative URL without a leading slash. 
In 3.2.5 the same call returns a relative URL with a leading slash. 

How to reproduce:

Using the following Model definition:

{{{
from django.contrib.gis.db import models

class TestModel(models.Model):
    file_field = models.FileField(
        upload_to='photos/%Y/%m/%d',
        max_length=255,
        null=True,
        help_text=u""Test""
    )
}}}

Using manage.py shell:
In 2.2.16
{{{
>>> test_model = models.TestModel.objects.create()
>>> f = open('setup.py')
>>> from django.core.files.base import File
>>> test_model.file_field.save('new_name', File(f))
>>> test_model.file_field.url
'photos/2021/08/05/new_name'
>>> import django
>>> django.__version__
'2.2.16'
}}}

In 3.2.5:

{{{
>>> from vault import models
>>> test_model = models.TestModel.objects.create()
>>> f = open('setup.py')
>>> from django.core.files.base import File
>>> test_model.file_field.save('new_name', File(f))
>>> test_model.file_field.url
'/photos/2021/08/05/new_name'
>>> import django
>>> django.__version__
'3.2.5'
}}}

The problem with the leading slash is that it is now treated as an absolute URL."	Bug	closed	contrib.staticfiles	3.2	Normal	invalid	FileField.url	Florian Apolloner	Unreviewed	0	0	0	0	1	0
