Skip to main content

Collections of libCST codemodders to upgrade Django

Project description

Django Codemod

PyPI Build Status Test Documentation Status Updates

All Contributors

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

Installation

Install this 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 --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 --removed-in 4.0 .

What happens

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.

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Bruno Alla

💻 🐛 📖

Adam Johnson

📖

Nikita Sobolev

📖

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

This version

0.8.0

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-0.8.0.tar.gz (23.8 kB view details)

Uploaded Source

Built Distribution

django_codemod-0.8.0-py2.py3-none-any.whl (15.2 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

  • Download URL: django-codemod-0.8.0.tar.gz
  • Upload date:
  • Size: 23.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.3

File hashes

Hashes for django-codemod-0.8.0.tar.gz
Algorithm Hash digest
SHA256 c1c8000315552b380f259929e7910795e6b867e069d8de751e27c8409ef41f53
MD5 9f002a88c7af69633103249d0f638a39
BLAKE2b-256 1daae16c616c5fa7a46b087b7e4e48efc9a765e0fb0750254537bc742a2772c4

See more details on using hashes here.

File details

Details for the file django_codemod-0.8.0-py2.py3-none-any.whl.

File metadata

  • Download URL: django_codemod-0.8.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 15.2 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.3

File hashes

Hashes for django_codemod-0.8.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 fbd056b5467ef7a46af393848cff95730b34da24dc78eaa3779eb8f7ea60392c
MD5 c997a7dcd160bcde2711a9786389a5b1
BLAKE2b-256 b6122b643dfd064ec318bff7f4a9076da90f765d8437c6c61ca1bc11711f22d3

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