From f4ada7cad520fdbfaba38f744a8300ec597a207f Mon Sep 17 00:00:00 2001 From: DanAtShenTech Date: Wed, 3 Apr 2019 15:50:32 -0400 Subject: [PATCH] Fix typo. Small grammar changes. --- docs/topics/streamfield.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/topics/streamfield.rst b/docs/topics/streamfield.rst index aa0a16b66e..470dbc54ce 100644 --- a/docs/topics/streamfield.rst +++ b/docs/topics/streamfield.rst @@ -942,7 +942,7 @@ Your extended value class methods will be available in your template: Custom block types ------------------ -If you need to implement a custom UI, or handle a datatype that is not provided by Wagtail's built-in block types (and cannot built up as a structure of existing fields), it is possible to define your own custom block types. For further guidance, refer to the source code of Wagtail's built-in block classes. +If you need to implement a custom UI, or handle a datatype that is not provided by Wagtail's built-in block types (and cannot be built up as a structure of existing fields), it is possible to define your own custom block types. For further guidance, refer to the source code of Wagtail's built-in block classes. For block types that simply wrap an existing Django form field, Wagtail provides an abstract class ``wagtail.core.blocks.FieldBlock`` as a helper. Subclasses just need to set a ``field`` property that returns the form field object: @@ -971,7 +971,7 @@ If you subclass any other block class, such as ``FieldBlock``, you will need to Migrating RichTextFields to StreamField ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -If you change an existing RichTextField to a StreamField, and create and run migrations as normal, the migration will complete with no errors, since both fields use a text column within the database. However, StreamField uses a JSON representation for its data, so the existing text needs to be converted with a data migration in order to become accessible again. For this to work, the StreamField needs to include a RichTextBlock as one of the available block types. The field can then be converted by creating a new migration (``./manage.py makemigrations --empty myapp``) and editing it as follows (in this example, the 'body' field of the ``demo.BlogPage`` model is being converted to a StreamField with a RichTextBlock named ``rich_text``): +If you change an existing RichTextField to a StreamField and create and run migrations as normal, the migration will complete with no errors, since both fields use a text column within the database. However, StreamField uses a JSON representation for its data, so the existing text needs to be converted with a data migration in order to become accessible again. For this to work, the StreamField needs to include a RichTextBlock as one of the available block types. The field can then be converted by creating a new migration (``./manage.py makemigrations --empty myapp``) and editing it as follows (in this example, the 'body' field of the ``demo.BlogPage`` model is being converted to a StreamField with a RichTextBlock named ``rich_text``): .. code-block:: python