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.

The problem

When maintaining a Django site, over time you'll find yourself to a point where you'll need to update to the next major version of Django. When Django APIs changes, functions move or are removed, changing usages in your project might add up to many changes. Often these changes are simple to do, but sometimes a simple "find and replace" is not possible.

Take, for instance, the removal of the url() function from Django 4.0, to be replaced by re_path(). In simple cases, you might even want to switch to path(), which has a nicer API. A typical Django project easily has 100's or routes, so this simple decision becomes a much longer task when to be made for each of them.

This solution

This project solves this problem by providing codemodders for simple changes like this. A codemodder re-writes your code from the old way to the new way.

With the help of AST analysis, we're able to understand what modifications are applicable, remove imports as they become irrelevant, and add missing ones as they are needed.

To continue the example, the tool will look at the route in the url() call, and decide whether the regular expression may be replaced by one of the built-in URL converters and use path() or stick to a regex and use re_path().

Interested? Check out the documentation for usage and the full list of codemodders.

What this tool is not

  • This tool is best suited for Django sites, NOT for reusable Django applications. The project needs to target a single Django version, e.g. 3.1.x.
  • You do NOT need to install this tool as part of your project dependencies, it is a CLI tool, not a Django package to be installed in your site.

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Bruno Alla

💻 📖 🤔

Aarni Koskela

💻 🤔 ⚠️

Adam Johnson

📖

Nikita Sobolev

📖

Chris VanderKolk

💻

John Vandenberg

🐛 💻

Anjishnu

🚇

Drew Winstel

🤔

Dmytro Litvinov

📖

M. Zulqarnain

📖

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

Uploaded Source

Built Distribution

django_codemod-1.6.3-py3-none-any.whl (33.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: django-codemod-1.6.3.tar.gz
  • Upload date:
  • Size: 26.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.12

File hashes

Hashes for django-codemod-1.6.3.tar.gz
Algorithm Hash digest
SHA256 4e13cd55667dcf332d3b29c5e8d9c892fd97936b1ceb8a24016cf1de43489bf1
MD5 13cb60912f89ebf360a1086ee4e7117f
BLAKE2b-256 235555e1f3c20510c719d7bbf3954eac0b8a008c0015adb51697464311744880

See more details on using hashes here.

File details

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

File metadata

  • Download URL: django_codemod-1.6.3-py3-none-any.whl
  • Upload date:
  • Size: 33.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.12

File hashes

Hashes for django_codemod-1.6.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a1d1320c48ea1b3316948cdb2f5054eb20935dec7631023430a9a8c3a8038b86
MD5 3febd2b2aca2557530b1163eb9035e41
BLAKE2b-256 556ee9784c313fb6b941d6943043384dbb231549eef06c22a7190c08f8139da7

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