django-deprecation is a Python library designed to facilitate the deprecation and renaming of Django model fields without introducing breaking changes to existing code or requiring immediate, complex database migrations. It helps maintain backward compatibility during phased rollouts, especially in environments with rolling deployments. The current version is 0.1.1, and its release cadence appears to be feature-driven rather than time-based.
pip install django-deprecationVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to use `DeprecatedField` to rename a model field (`musician` to `artist`) while maintaining backward compatibility for existing code that still references the old field name. The `DeprecatedField` ensures that lookups and access via the old name are correctly redirected to the new field. This typically involves a multi-step migration process.
Implement a phased rollout: 1. Add `DeprecatedField` pointing to the new field, deploy, run `makemigrations` and `migrate`. 2. After all instances are updated, refactor code to use the new field. 3. Finally, remove the `DeprecatedField` entirely, deploy, run `makemigrations` and `migrate` again. This ensures database schema compatibility at each stage.
Understand the distinct use cases. Use `django-deprecation.DeprecatedField` for seamless runtime field aliasing and query redirection. Use Django's `system_check_deprecated_details` on custom fields for static code analysis warnings to guide developers away from deprecated usage during development.
Verify the `pypi-slug` and `source_url` for the library you intend to use. This entry specifically refers to `openbox/django-deprecation` (version 0.1.1) imported as `django_deprecation`. Check your `requirements.txt` and `setup.py` for clarity.