I’ve been on Django 4.2 (supported until April 2026), but with 5.2 (the latest long-term support version) out since December, I wanted to go ahead and upgrade.
I encountered two deprecation warnings along the way.
STATICFILES_STORAGE setting is deprecated
Running the site locally with python -Wa manage.py runserver
(the -Wa
flag outputs warnings to the console) resulted in
RemovedInDjango51Warning: The STATICFILES_STORAGE setting is deprecated. Use STORAGES instead.
warnings.warn(STATICFILES_STORAGE_DEPRECATED_MSG, RemovedInDjango51Warning)
The warning came from this line in settings.py
STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.ManifestStaticFilesStorage'
The fix was to change that to
STORAGES = {
'default': {
'BACKEND': 'django.contrib.staticfiles.storage.FileSystemStorage'
},
'staticfiles': {
'BACKEND': 'django.contrib.staticfiles.storage.ManifestStaticFilesStorage'
}
}
I went ahead and deployed that one change last week. I wanted to make sure it was fine in production before continuing with upgrading Django.
The default scheme will be changed from 'http' to 'https' in Django 6.0
After upgrading to 5.0, I got this warning
RemovedInDjango60Warning: The default scheme will be changed from 'http' to 'https' in Django 6.0. Pass the forms.URLField.assume_scheme argument to silence this warning, or set the FORMS_URLFIELD_ASSUME_HTTPS transitional setting to True to opt into using 'https' as the new default scheme.
This one’s both easier and trickier. It’s easier because it seems to be warning me about something I don’t need to worry about. I’m fine with the default scheme changing to https
. I found this blog post about it.
So I can either opt-in to the new behavior now with the FORMS_URLFIELD_ASSUME_HTTPS=True
setting or update every URLField
with assume_scheme="https"
.
The problem with the first option is that it outputs a new warning about that settings option being removed in 6.0, which makes sense because it only exists because of this deprecation warning that will go away in 6.0. The problem with the second options is that it’s adding a lot of code that will eventually become obsolete.
I opted for the first option and will deal with the ongoing warnings.
RemovedInDjango60Warning: The FORMS_URLFIELD_ASSUME_HTTPS transitional setting is deprecated.
With that warning “resolved,” upgrading to 5.1 and then 5.2 locally were without issue. I deployed the final 4.2-to-5.2 change today.
I’m happy to get this upgrade done. Changes like this make me nervous.