Make these fixers work when
django.contrib.gis.db.models
is used to import objects fromdjango.db.models
:check_constraint_condition
index_together
Fix circular import error when running django-upgrade.
Thanks to Michal Čihař for the report in Issue #503.
Avoid accidental removal of comments a removed
if
block in the versioned block fixer.Thanks to Tobias Funke for the report in Issue #495.
Add all-version fixer to remove outdated test skip decorators.
Drop Python 3.8 support.
Support Python 3.13.
Add Django 5.0+ fixer to rewrite
format_html()
calls withoutargs
orkwargs
probably usingstr.format()
incorrectly.
Fix the
admin_register
fixer to avoid rewriting when there are duplicateModelAdmin
classes in the file.
Add Django 4.2+ fixer to rewrite
index_together
declarations intoindexes
declarations in modelMeta
classes. This fixer can make changes that require migrations. Add a test for pending migrations to ensure that you do not miss these.Fix tracking of AST node parents. This may have fixed some subtle bugs in these fixers:
admin_register
assert_form_error
default_app_config
management_commands
request_headers
settings_database_postgresql
settings_storages
testcase_databases
use_l10n
utils_timezone
If you see any new changes, or had them previously disabled, please report an issue so we can extra tests to the test suite.
- Support Django 5.1 as a target version.
- Add Django 5.1+ fixer to rewrite the
check
keyword argument ofCheckConstraint
tocondition
.
Add fixer selection options:
--only <name>
,--skip <name>
, and--list-fixers
.Thanks to Gav O'Connor and David Szotten in PR #443.
Run per-file conditions once, yielding a performance improvement of ~2% measured on a real-world project.
Remove the Django 5.0+ fixer that dropped
.choices
from model fieldchoices
parameters. It was too unreliable because it could break use for “DIY” enumeration types.Thanks to Niccolò Mineo and washeck for reporting in Issue #417.
Add Django 1.10+ fixer to rewrite
request.user
functions that changed to boolean attributes:is_authenticated
andis_anonymous
.Thanks to Alessandro Ferrini in PR #423.
Add Django 2.0+ imports fixes for names moved from
django.core.urlresolvers
todjango.urls
.Thanks to Thibaut Decombe in PR #404.
Support Django 5.0 as a target version.
Add Django 5.0+ fixer to drop
.choices
on model fieldchoices
parameters when using an enumeration type.Thanks to Thibaut Decombe in PR #369.
Add some compatibility import replacements for Django 4.0 and below.
Thanks to Thibaut Decombe in PR #368.
Fix issue with
@admin.register()
checkerThanks to Jan Pieter Waagmeester for the report in Issue #337, and to Thibaut Decombe for the review in PR #338.
Fix bug in
STORAGES
fixer when only one ofDEFAULT_FILE_STORAGE
orSTATICFILES_STORAGE
was defined.Thanks to Bruno Alla in PR #376.
- Support Python 3.12.
Add Django 4.2+ fixer to combine deprecated
DEFAULT_FILE_STORAGE
andSTATICFILES_STORAGE
settings into the newSTORAGES
setting.Add Django 4.2+ fixer to rewrite HTTP headers passed to test
Client
andRequestFactory
.Thanks to David Wobrock in PR #305.
Add Django 4.2+ fixer to rewrite test case methods
assertFormsetError()
andassertQuerysetEqual()
into the new spellings with capitalized “Set”.Thanks to Michael Howitz in PR #253.
Add Django 4.0 fixer to rewrite
django.contrib.admin.utils.lookup_needs_distinct
->lookup_spawns_duplicates
.Thanks to Bruno Alla in PR #313.
Rewrite
request.META
->request.headers
on the right hand side of assignments.Group some compatibility import replacements into a single “fixer”, optimizing runtime by about 3%.
Thanks to Thibaut Decombe in PR #295.
Make
re_path
->path
fixer also convertinclude()
's with unterminated regexes.Thanks to Thibaut Decombe in PR #279.
Avoid rewriting
request.META
torequest.headers
indel
statements. This pattern works forrequest.META
but not forrequest.headers
which is an immutable mapping.Thanks to Thibaut Decombe in PR #290.
Add Django 1.9+ fixer to rename the legacy engine name
django.db.backends.postgresql_psycopg2
insettings.DATABASES
todjango.db.backends.postgresql
.Thanks to Thibaut Decombe in PR #280.
Make detection of management commands and migration files detect both forward and backward slashes as directory separators.
Thanks to William Claassen in PR #286.
See also the release blog post.
Add Django 1.7+ fixer to rewrite
admin.site.register()
calls into@admin.register()
when eligible.Thanks to Thibaut Decombe in PR #189.
Add Django 3.2+ fixer to rewrite admin action function attributes to use the
@admin.action()
decorator.Add Django 3.2+ fixer to rewrite admin display function attributes to use the
@admin.display()
decorator.Add Django 4.1+ fixer to rewrite calls to test case methods
assertFormError()
andassertFormsetError()
from their old signatures to the new ones.Add Django 2.0+ fixer to drop assignments of
allow_tags
attributes toTrue
.Add Django 3.1+ fixer to replace
list
error message key withlist_invalid
onModelMultipleChoiceField
.Thanks to Thibaut Decombe in PR #258.
Make
request.headers
fixer also rewrite accesses of thecontent-length
andcontent-type
headers.Thanks to Christian Bundy in PR #226.
Extend
request.headers
fixer to rewritein
andnot in
comparisons onrequest.META
.Thanks to Daan Vielen in Issue #234.
The
request.headers
fixer now uses lowercase for header lookups, as per the HTTP/2 specification.Make
on_delete
fixer also supportForeignKey
andOneToOneField
imported fromdjango.db.models
.Thanks to Thibaut Decombe in PR #236.
Make
NullBooleanField
fixer preserve existingnull
arguments.Thanks to Joseph Zammit in Issue #245.
Update
timezone.utc
fixer to only use absolute references from existing imports of thedatetime
module.Make Django 2.0+ URL fixer avoid a loop of adding imports that already exist.
Thanks to Benjamin Bach for the report in Issue #250, and to Thibaut Decombe for the fix in PR #270.
Fixers that modify string literals now match existing use of double quotes.
Thanks to Kevin Marsh in PR #260.
Make fixers that erase lines also erase any trailing comments.
Fix leaving a trailing comma when editing imports in certain cases.
Expand the range of files considered settings files.
Require at least one filename.
Thanks to Daan Vielen in Issue #238.
Update README with info on how to run an upgrade on entire project.
Thanks to Daan Vielen in Issue #240.
Add Django 3.2+ fixer to update
requires_system_checks
in management command classes.Thanks to Bruno Alla in PR #184.
Add Django 4.0+ fixer to remove
USE_L10N = True
setting.Thanks to Johnny Metz in PR #173.
Add fixer to remove outdated blocks based on comparing
django.VERSION
to old versions:-if django.VERSION > (4, 1): - constraint.validate() +constraint.validate()
Update Django 2.0+ URL fixer to rewrite
re_path()
calls intopath()
when eligible.Thanks to Thibaut Decombe in PR #167.
Fix
timezone.utc
fixer to import and usetimezone.utc
correctly.Thanks to Víðir Valberg Guðmundsson for the report in Issue #172.
Support Django 4.1 as a target version.
Add Django 4.1+ fixer to rewrite imports of
utc
fromdjango.utils.timezone
to usedatetime.timezone
.Thanks to Hasan Ramezani in PR #169.
- Support Python 3.11.
Fix
default_app_config
fixer to work with__init__.py
files in subdirectories.Thanks to Bruno Alla in PR #144.
Add
--version
flag.Thanks to Ferran Jovell in PR #143.
Add Django 3.2+ fixer to remove
default_app_config
assignments in__init__.py
files.Thanks to Bruno Alla in PR #140.
Fix URL rewriting to avoid converting regular expressions that don’t end with
$
. If the$
is missing, Django will search for the given regular expression anywhere in the path.Thanks to qdufrois for the report in Issue #121.
Made
JSONField
andNullBooleanField
fixers ignore migrations files. Django kept these old field classes around for use in historical migrations, so there’s no need to rewrite such cases.Thanks to Matthieu Rigal and Bruno Alla for the report in Issue #79.
- Add Django 2.0+ fixer to rewrite imports of
lru_cache
fromdjango.utils.functional
to usefunctools
. - Support Django 4.0 as a target version. There are no fixers for it at current. Most of its deprecations don’t seem automatically fixable.
Avoid rewriting
request.META
torequest.headers
in assignments. This pattern is used in tests, and works forrequest.META
but notrequest.headers
.Thanks to Bruno Alla for the report in Issue #74.
Fix import fixers to not crash on star imports (
from foo import *
).Thanks to Mikhail for the report in Issue #70.
Fix
get_random_string()
fixer to not add the argument to calls likecrypto.get_random_string(12)
.Add fixers to remove various compatibility imports removed in Django 3.1.
Thanks to Bruno Alla in PR #44.
Add fixer for Django 2.2 to rewrite
request.META
access of headers toHttpRequest.headers
.Add fixer for Django 2.0 to rewrite
include()
andurl()
fromdjango.conf.urls
todjango.urls
.url()
may be rewritten topath()
orre_path()
accordingly.Thanks to Bruno Alla for the original implementation of regex-to-path conversion in django-codemod. Thanks to Matthias Kestenholz for an initial PR.
Add fixer for Django 1.9 requirement to pass
on_delete
toForeignKey
andOneToOneField
.Thanks to Bruno Alla in PR #61.
- Support Python 3.10.
- Support single level module imports of names too, such as using o
from django.utils import crypto
withcrypto.get_random_string()
. - Add fixer for Django 3.1 deprecation of
NullBooleanField
. - Add fixers for Django 3.0 deprecation of functions in
django.utils.http
,django.utils.text
, anddjango.utils.translation
. - Add fixer for Django 2.2 rename of
FloatRangeField
toDecimalRangeField
. - Add fixer for Django 2.2 deprecation of test case attributes
allow_database_queries
andmulti_db
. - Fix inserted imports to match indentation of the point they are inserted.
- Add fixer for Django 3.1
JSONField
moves. - Add fixer for Django 3.1 removal of
Signal
’s argumentproviding_args
. - Add fixer for Django 3.1 requirement to pass
get_random_string()
thelength
argument. - Fix Python 3.8 compatibility.
- Drop Python 3.6 and 3.7 support, since they never worked, and the incompatibilities in the
ast
module are hard to cover.
- Initial release.