# Django - Deprecate Field
[](https://pypi.python.org/pypi/django-deprecate-fields/)
[](./LICENSE)
[](https://github.com/3YOURMIND/django-deprecate-fields/pulls)
[](https://github.com/3YOURMIND/django-deprecate-fields/stargazers)
## Installation
```
pip install django-deprecate-fields
```
## Usage
Assume the simple following model:
```python
from django.db import models
class MyModel(models.Model):
field1 = models.CharField()
field2 = models.CharField()
```
In order to remove `field1`, it should first be marked as deprecated:
```python
from django.db import models
from django_deprecate_fields import deprecate_field
class MyModel(models.Model):
field1 = deprecate_field(models.CharField())
field2 = models.CharField()
```
Secondly, `makemigrations` should be called, which will change the field to be nullable. Any lingering references to it
in your code will return `None` (or optionally any value or callable passed to `deprecate_field` as the
`return_instead` argument)
Lastly, after the changes above have been deployed, `field1` can then safely be removed in the model (plus another
`makemigrations` run)
### Custom django commands
If you need the actual field to be returned when a django command other
than `makemigrations`, `migrate` or `showmigrations` is run, you can specify the
`DEPRECATE_FIELD_CUSTOM_MIGRATION_COMMAND` parameter in the settings.
For instance if you generate migrations with `pgmakemigrations` instead of `makemigrations`,
you can add this to your settings:
```python
DEPRECATE_FIELD_CUSTOM_MIGRATION_COMMAND = {"pgmakemigrations"}
```
## Contributing
First of all, thank you very much for contributing to this project. Please base
your work on the `master` branch and target `master` in your pull request.
## License
`django-deprecate-fields` is released under the [Apache 2.0 License](./LICENSE).
Raw data
{
"_id": null,
"home_page": "https://github.com/3YOURMIND/django-deprecate-fields",
"name": "django-deprecate-fields",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "django migration deprecation database backward compatibility",
"author": "3YOURMIND GmbH",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/5d/bc/bb6cff1e462a258cc077915e928aec62ccfeeaf2ea1eb035865891ab91a3/django_deprecate_fields-0.2.2.tar.gz",
"platform": null,
"description": "# Django - Deprecate Field\n\n[](https://pypi.python.org/pypi/django-deprecate-fields/)\n[](./LICENSE)\n[](https://github.com/3YOURMIND/django-deprecate-fields/pulls)\n[](https://github.com/3YOURMIND/django-deprecate-fields/stargazers)\n\n## Installation\n\n```\npip install django-deprecate-fields\n```\n\n## Usage\n\nAssume the simple following model:\n```python\nfrom django.db import models\n\nclass MyModel(models.Model):\n field1 = models.CharField()\n field2 = models.CharField()\n```\n\nIn order to remove `field1`, it should first be marked as deprecated:\n```python\nfrom django.db import models\nfrom django_deprecate_fields import deprecate_field\n\nclass MyModel(models.Model):\n field1 = deprecate_field(models.CharField())\n field2 = models.CharField()\n```\n\nSecondly, `makemigrations` should be called, which will change the field to be nullable. Any lingering references to it\nin your code will return `None` (or optionally any value or callable passed to `deprecate_field` as the\n`return_instead` argument)\n\nLastly, after the changes above have been deployed, `field1` can then safely be removed in the model (plus another\n`makemigrations` run)\n\n### Custom django commands\n\nIf you need the actual field to be returned when a django command other \nthan `makemigrations`, `migrate` or `showmigrations` is run, you can specify the \n`DEPRECATE_FIELD_CUSTOM_MIGRATION_COMMAND` parameter in the settings.\n\nFor instance if you generate migrations with `pgmakemigrations` instead of `makemigrations`, \nyou can add this to your settings:\n```python\nDEPRECATE_FIELD_CUSTOM_MIGRATION_COMMAND = {\"pgmakemigrations\"}\n```\n\n\n## Contributing\n\nFirst of all, thank you very much for contributing to this project. Please base\nyour work on the `master` branch and target `master` in your pull request.\n\n## License\n\n`django-deprecate-fields` is released under the [Apache 2.0 License](./LICENSE).\n",
"bugtrack_url": null,
"license": "Apache License 2.0",
"summary": "This package allows deprecating model fields and allows removing them in a backwards compatible manner.",
"version": "0.2.2",
"project_urls": {
"Homepage": "https://github.com/3YOURMIND/django-deprecate-fields"
},
"split_keywords": [
"django",
"migration",
"deprecation",
"database",
"backward",
"compatibility"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "9a852d62f543dc74169da6e130a7e428b7b9ea1fe51466eb5a0940d982d838f6",
"md5": "613fd053155e62ae9de687c0e9300541",
"sha256": "0f28ee320a2196119d13959a2286aa3441d8aeed33c1683250b3477622f6c1a1"
},
"downloads": -1,
"filename": "django_deprecate_fields-0.2.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "613fd053155e62ae9de687c0e9300541",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 8276,
"upload_time": "2025-07-15T11:52:42",
"upload_time_iso_8601": "2025-07-15T11:52:42.964000Z",
"url": "https://files.pythonhosted.org/packages/9a/85/2d62f543dc74169da6e130a7e428b7b9ea1fe51466eb5a0940d982d838f6/django_deprecate_fields-0.2.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "5dbcbb6cff1e462a258cc077915e928aec62ccfeeaf2ea1eb035865891ab91a3",
"md5": "d38bc5363888c9f7a7ce2db586090fb4",
"sha256": "ddca9afbf95639d550afc66f9ec7e28f6ffe5b7c3d0b8eadb7a5c54bc90c44e2"
},
"downloads": -1,
"filename": "django_deprecate_fields-0.2.2.tar.gz",
"has_sig": false,
"md5_digest": "d38bc5363888c9f7a7ce2db586090fb4",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 7437,
"upload_time": "2025-07-15T11:52:45",
"upload_time_iso_8601": "2025-07-15T11:52:45.156129Z",
"url": "https://files.pythonhosted.org/packages/5d/bc/bb6cff1e462a258cc077915e928aec62ccfeeaf2ea1eb035865891ab91a3/django_deprecate_fields-0.2.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-15 11:52:45",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "3YOURMIND",
"github_project": "django-deprecate-fields",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "django-deprecate-fields"
}