Skip to content

Commit 463c415

Browse files
GRazvan12Photonios
authored andcommitted
Add deconstruct method for LocalizedBleachField for it to be recognized in django migrations
1 parent fbc1eec commit 463c415

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

localized_fields/fields/bleach_field.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,23 @@ class LocalizedBleachField(LocalizedField):
99
"""Custom version of :see:BleachField that is actually a
1010
:see:LocalizedField."""
1111

12+
DEFAULT_SHOULD_ESCAPE = True
13+
1214
def __init__(self, *args, escape=True, **kwargs):
1315
"""Initializes a new instance of :see:LocalizedBleachField."""
1416

1517
self.escape = escape
1618

1719
super().__init__(*args, **kwargs)
1820

21+
def deconstruct(self):
22+
name, path, args, kwargs = super().deconstruct()
23+
24+
if self.escape != self.DEFAULT_SHOULD_ESCAPE:
25+
kwargs["escape"] = self.escape
26+
27+
return name, path, args, kwargs
28+
1929
def pre_save(self, instance, add: bool):
2030
"""Ran just before the model is saved, allows us to built the slug.
2131

0 commit comments

Comments
 (0)