Skip to content

Commit ecf6e09

Browse files
committed
[fix]: Prevent FallbackMixin from generating spurious migrations
The deconstruct() method was serializing the fallback kwarg into Django migration files. This caused new migrations to be generated whenever the fallback default value changed in settings, even though no actual database schema change had occurred. The fix removes fallback from deconstruct() so Django no longer tracks it as part of the field migration state. fallback is also made optional in __init__ (defaulting to None) so existing migrations that omit the kwarg remain valid. Fixes: #1231
1 parent 288e8cc commit ecf6e09

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

openwisp_utils/fields.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,13 @@ class FallbackMixin(object):
4848
"""
4949

5050
def __init__(self, *args, **kwargs):
51-
self.fallback = kwargs.pop("fallback")
51+
self.fallback = kwargs.pop("fallback", None)
5252
opts = dict(blank=True, null=True, default=None)
5353
opts.update(kwargs)
5454
super().__init__(*args, **opts)
5555

5656
def deconstruct(self):
5757
name, path, args, kwargs = super().deconstruct()
58-
kwargs["fallback"] = self.fallback
5958
return (name, path, args, kwargs)
6059

6160
def from_db_value(self, value, expression, connection):

0 commit comments

Comments
 (0)