Collections of libCST codemodders to upgrade Django
A tool to help upgrade Django projects to newer version of the framework by automatically fixing deprecations.
Install this via pip (or your favourite installer):
pip install django-codemod
2 main workflow are supported:
- Prepare future upgrades by modifying code which is deprecated in a given version using the
- Fix previous deprecated code which is removed in a given version using the
Let's say you just updated to Django 3.0, and suddenly you're flooded with deprecations warning on your CI (you have warning enabled on CI, right?).
You want to resolve them to avoid missing another important warning. You can do so by running the following command from the root of your repo:
djcodemod run --deprecated-in 3.0 .
This is more a just in time operation, assuming you haven't kept up to date with deprecation warnings, and right before upgrading to a given version (let's assume Django 4.0). In this case, you should be running:
djcodemod run --removed-in 4.0 .
In either case, the tool will take a few minutes and apply a set of modifications to your code to fix deprecated or removed usages of Django. This should be much faster than doing it manually and much robust than a simple find & replace.
Check out the documentation for more detail on usage and the full list of codemodders.
How it works
This is based on libCST and implements codemods for it. This is currently very limited but the aim is to add more for helping with upcoming deprecations.
Not finding what you need? I'm open to contributions, please send me a pull request.
Thanks goes to these wonderful people (emoji key):
💻 🐛 📖
This project follows the all-contributors specification. Contributions of any kind welcome!
Release history Release notifications | RSS feed
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size django_codemod-0.13.0-py2.py3-none-any.whl (20.0 kB)||File type Wheel||Python version py2.py3||Upload date||Hashes View|
|Filename, size django-codemod-0.13.0.tar.gz (26.2 kB)||File type Source||Python version None||Upload date||Hashes View|
Hashes for django_codemod-0.13.0-py2.py3-none-any.whl