Skip to content

Commit f8e310f

Browse files
committed
Merge pull request #2371 from robbyt/patch-4
fix the serializer widget style formatting documentation
2 parents 4bca062 + 336faf5 commit f8e310f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

docs/tutorial/1-serialization.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ The first part of the serializer class defines the fields that get serialized/de
124124

125125
A serializer class is very similar to a Django `Form` class, and includes similar validation flags on the various fields, such as `required`, `max_length` and `default`.
126126

127-
The field flags can also control how the serializer should be displayed in certain circumstances, such as when rendering to HTML. The `style={'type': 'textarea'}` flag above is equivelent to using `widget=widgets.Textarea` on a Django `Form` class. This is particularly useful for controlling how the browsable API should be displayed, as we'll see later in the tutorial.
127+
The field flags can also control how the serializer should be displayed in certain circumstances, such as when rendering to HTML. The `{'base_template': 'textarea.html'}` flag above is equivelent to using `widget=widgets.Textarea` on a Django `Form` class. This is particularly useful for controlling how the browsable API should be displayed, as we'll see later in the tutorial.
128128

129129
We can actually also save ourselves some time by using the `ModelSerializer` class, as we'll see later, but for now we'll keep our serializer definition explicit.
130130

@@ -206,7 +206,7 @@ One nice property that serializers have is that you can inspect all the fields i
206206
SnippetSerializer():
207207
id = IntegerField(label='ID', read_only=True)
208208
title = CharField(allow_blank=True, max_length=100, required=False)
209-
code = CharField(style={'type': 'textarea'})
209+
code = CharField(style={'base_template': 'textarea.html'})
210210
linenos = BooleanField(required=False)
211211
language = ChoiceField(choices=[('Clipper', 'FoxPro'), ('Cucumber', 'Gherkin'), ('RobotFramework', 'RobotFramework'), ('abap', 'ABAP'), ('ada', 'Ada')...
212212
style = ChoiceField(choices=[('autumn', 'autumn'), ('borland', 'borland'), ('bw', 'bw'), ('colorful', 'colorful')...

0 commit comments

Comments
 (0)