mirror of
https://github.com/SectorLabs/django-localized-fields.git
synced 2025-06-27 22:03:21 +03:00
Add deconstruct method for LocalizedBleachField for it to be recognized in django migrations
This commit is contained in:
parent
fbc1eec754
commit
463c415be2
@ -9,6 +9,8 @@ class LocalizedBleachField(LocalizedField):
|
|||||||
"""Custom version of :see:BleachField that is actually a
|
"""Custom version of :see:BleachField that is actually a
|
||||||
:see:LocalizedField."""
|
:see:LocalizedField."""
|
||||||
|
|
||||||
|
DEFAULT_SHOULD_ESCAPE = True
|
||||||
|
|
||||||
def __init__(self, *args, escape=True, **kwargs):
|
def __init__(self, *args, escape=True, **kwargs):
|
||||||
"""Initializes a new instance of :see:LocalizedBleachField."""
|
"""Initializes a new instance of :see:LocalizedBleachField."""
|
||||||
|
|
||||||
@ -16,6 +18,14 @@ class LocalizedBleachField(LocalizedField):
|
|||||||
|
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
def deconstruct(self):
|
||||||
|
name, path, args, kwargs = super().deconstruct()
|
||||||
|
|
||||||
|
if self.escape != self.DEFAULT_SHOULD_ESCAPE:
|
||||||
|
kwargs["escape"] = self.escape
|
||||||
|
|
||||||
|
return name, path, args, kwargs
|
||||||
|
|
||||||
def pre_save(self, instance, add: bool):
|
def pre_save(self, instance, add: bool):
|
||||||
"""Ran just before the model is saved, allows us to built the slug.
|
"""Ran just before the model is saved, allows us to built the slug.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user