django-upgrade is a tool that automatically upgrades your Django project code. It changes code to avoid deprecation warnings and migrates some patterns to newer Django idioms, easing the upgrade process and helping ensure your code uses the latest features. It is currently at version 1.30.0 and is actively maintained.
pip install django-upgradeNo compatibility data collected yet for this library.
django-upgrade is primarily a command-line tool. You typically run it against your project's Python files, optionally specifying a target Django version. It modifies files in-place by default.
Commit pending changes, run `django-upgrade`, then meticulously review `git diff` and run your full test suite. Consider integrating it with `pre-commit` to catch new deprecations early.
Upgrade your Python environment to 3.10 or later before attempting to upgrade Django or use `django-upgrade` for newer Django versions.
Order your tooling: run `django-upgrade` first, then formatters like Black/Ruff.
Always consult Django's release notes for each target version you are upgrading through, focusing on 'Backwards incompatible changes' and 'Deprecations'.
Upgrade your database server (e.g., PostgreSQL to 14+, MySQL to 8.0+) before or during your Django 5.2 upgrade process.
Install the package using pip: `pip install django-upgrade`
Run `django-upgrade` to automatically add `on_delete` arguments, typically `models.CASCADE`, `models.SET_NULL`, or `models.PROTECT`, to your ForeignKey and OneToOneField definitions: `django-upgrade .`
Run `django-upgrade` to automatically add `app_name` attributes to your `urls.py` files or pass the `app_name` explicitly in the `include()` call: `django-upgrade .`
Run `django-upgrade` to automatically replace `from django.utils.timezone import utc` with `from datetime import timezone; utc = timezone.utc` or similar fixes: `django-upgrade .`
No dependency data recorded yet.