mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-05 05:54:44 +00:00
Replaced SubFieldBase with Field.from_db_value. Fixes #2070
This commit is contained in:
parent
921a510d9f
commit
480aca681f
1 changed files with 5 additions and 2 deletions
|
|
@ -4,7 +4,7 @@ import json
|
|||
|
||||
from django.core.serializers.json import DjangoJSONEncoder
|
||||
from django.db import models
|
||||
from django.utils.six import string_types, with_metaclass
|
||||
from django.utils.six import string_types
|
||||
|
||||
from wagtail.wagtailcore.blocks import Block, BlockField, StreamBlock, StreamValue
|
||||
|
||||
|
|
@ -21,7 +21,7 @@ class RichTextField(models.TextField):
|
|||
return super(RichTextField, self).formfield(**defaults)
|
||||
|
||||
|
||||
class StreamField(with_metaclass(models.SubfieldBase, models.Field)):
|
||||
class StreamField(models.Field):
|
||||
def __init__(self, block_types, **kwargs):
|
||||
if isinstance(block_types, Block):
|
||||
self.stream_block = block_types
|
||||
|
|
@ -89,6 +89,9 @@ class StreamField(with_metaclass(models.SubfieldBase, models.Field)):
|
|||
else:
|
||||
return json.dumps(self.stream_block.get_prep_value(value), cls=DjangoJSONEncoder)
|
||||
|
||||
def from_db_value(self, value, expression, connection, context):
|
||||
return self.to_python(value)
|
||||
|
||||
def formfield(self, **kwargs):
|
||||
"""
|
||||
Override formfield to use a plain forms.Field so that we do no transformation on the value
|
||||
|
|
|
|||
Loading…
Reference in a new issue