Skip to main content

A command line tool to automatically fix Django deprecations.

Project description

Django Codemod

CI Status Documentation Status Test coverage percentage

Poetry black pre-commit

PyPi Status pyversions license LoC

A tool to help upgrade Django projects to newer version of the framework by automatically fixing deprecations.

Installation

Install via pip (or your favourite installer):

pip install django-codemod

Usage

2 main workflow are supported:

  • Prepare future upgrades by modifying code which is deprecated in a given version using the deprecated-in option
  • Fix previous deprecated code which is removed in a given version using the removed-in option

1. Deprecations

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 .

2. Removals

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 .

Explanations

In either case, the tool will run for 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.

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Bruno Alla

💻 📖 🤔

Aarni Koskela

💻 🤔 ⚠️

Adam Johnson

📖

Nikita Sobolev

📖

Chris VanderKolk

💻

John Vandenberg

🐛 💻

Anjishnu

🚇

This project follows the all-contributors specification. Contributions of any kind welcome!

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-codemod-1.0.0.tar.gz (21.7 kB view details)

Uploaded Source

Built Distribution

django_codemod-1.0.0-py3-none-any.whl (27.4 kB view details)

Uploaded Python 3

File details

Details for the file django-codemod-1.0.0.tar.gz.

File metadata

  • Download URL: django-codemod-1.0.0.tar.gz
  • Upload date:
  • Size: 21.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.9

File hashes

Hashes for django-codemod-1.0.0.tar.gz
Algorithm Hash digest
SHA256 5b32ed45ef77fd0417474f4df53863e5b12385280f826c8c9d07606008e35dc0
MD5 57d6ff005959ec2576bfdea2fcdb3be8
BLAKE2b-256 431f125e5092f26a915b9e644bb0cd07c10685dd6fbfad4a7358f0a8e04da7dd

See more details on using hashes here.

File details

Details for the file django_codemod-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: django_codemod-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 27.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.9

File hashes

Hashes for django_codemod-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 765e43dac04a89d9ae7cd35be3272a83bbdbb207fc017fe3b8ad2e62e492169d
MD5 36cc6dd702a672a8cf5f58b5ac2d6193
BLAKE2b-256 a87dd9d73c14374c237a50c67ab7f1c02c22fc2f65a9591cfa8061256d074fd7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page