Skip to main content

This package allows deprecating model fields and allows removing them in a backwards compatible manner.

Project description

Django - Deprecate Field

PyPi License Contributing 3yourminD-Careers Stars


pip install django-deprecate-fields


Assume the simple following model:

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:

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)


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.


django-deprecate-fields is released under the Apache 2.0 License.

Project details

Download files

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

Source Distribution

django-deprecate-fields-0.1.2.tar.gz (7.2 kB view hashes)

Uploaded Source

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