mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-26 03:23:59 +03:00
Make code block consistent in serialization tutorial
All the other code blocks in the Serialization tutorial can be copied and pasted, but there is one that includes the >>> shell prompt characters. This commit removes those characters, and also makes the output consistent with other code blocks by making it a comment.
This commit is contained in:
parent
dafbe65ff6
commit
2d7d3b79a0
|
@ -193,16 +193,16 @@ Open the file `snippets/serializers.py` again, and replace the `SnippetSerialize
|
||||||
|
|
||||||
One nice property that serializers have is that you can inspect all the fields in a serializer instance, by printing its representation. Open the Django shell with `python manage.py shell`, then try the following:
|
One nice property that serializers have is that you can inspect all the fields in a serializer instance, by printing its representation. Open the Django shell with `python manage.py shell`, then try the following:
|
||||||
|
|
||||||
>>> from snippets.serializers import SnippetSerializer
|
from snippets.serializers import SnippetSerializer
|
||||||
>>> serializer = SnippetSerializer()
|
serializer = SnippetSerializer()
|
||||||
>>> print(repr(serializer))
|
print(repr(serializer))
|
||||||
SnippetSerializer():
|
# SnippetSerializer():
|
||||||
id = IntegerField(label='ID', read_only=True)
|
# id = IntegerField(label='ID', read_only=True)
|
||||||
title = CharField(allow_blank=True, max_length=100, required=False)
|
# title = CharField(allow_blank=True, max_length=100, required=False)
|
||||||
code = CharField(style={'base_template': 'textarea.html'})
|
# code = CharField(style={'base_template': 'textarea.html'})
|
||||||
linenos = BooleanField(required=False)
|
# linenos = BooleanField(required=False)
|
||||||
language = ChoiceField(choices=[('Clipper', 'FoxPro'), ('Cucumber', 'Gherkin'), ('RobotFramework', 'RobotFramework'), ('abap', 'ABAP'), ('ada', 'Ada')...
|
# language = ChoiceField(choices=[('Clipper', 'FoxPro'), ('Cucumber', 'Gherkin'), ('RobotFramework', 'RobotFramework'), ('abap', 'ABAP'), ('ada', 'Ada')...
|
||||||
style = ChoiceField(choices=[('autumn', 'autumn'), ('borland', 'borland'), ('bw', 'bw'), ('colorful', 'colorful')...
|
# style = ChoiceField(choices=[('autumn', 'autumn'), ('borland', 'borland'), ('bw', 'bw'), ('colorful', 'colorful')...
|
||||||
|
|
||||||
It's important to remember that `ModelSerializer` classes don't do anything particularly magical, they are simply a shortcut for creating serializer classes:
|
It's important to remember that `ModelSerializer` classes don't do anything particularly magical, they are simply a shortcut for creating serializer classes:
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user