You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I get this error when I want to test my code using factory-boy:
AttributeError: 'str' object has no attribute 'raw'. See also this question on stackoverflow.
Therefore I have to subclass the MarkupField:
from markitup.fields import render_func, _rendered_field_name
class MyMarkupField(MarkupField):
def value_to_string(self, obj):
value = self._get_val_from_obj(obj)
if hasattr(value, "raw"):
return value.raw
return value
def pre_save(self, model_instance, add):
value = super(MarkupField, self).pre_save(model_instance, add)
if hasattr(value, "raw"):
value = value.raw
elif value is None:
value = ''
rendered = render_func(value)
setattr(model_instance, _rendered_field_name(self.attname), rendered)
return value
This isn't ideal. Can we fix this, please?
The text was updated successfully, but these errors were encountered:
I get this error when I want to test my code using factory-boy:
AttributeError: 'str' object has no attribute 'raw'
. See also this question on stackoverflow.Therefore I have to subclass the
MarkupField
:This isn't ideal. Can we fix this, please?
The text was updated successfully, but these errors were encountered: