Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions localized_fields/fields/bleach_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,23 @@ class LocalizedBleachField(LocalizedField):
"""Custom version of :see:BleachField that is actually a
:see:LocalizedField."""

DEFAULT_SHOULD_ESCAPE = True

def __init__(self, *args, escape=True, **kwargs):
"""Initializes a new instance of :see:LocalizedBleachField."""

self.escape = escape

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):
"""Ran just before the model is saved, allows us to built the slug.

Expand Down