diff options
| author | Xavier Ordoquy | 2015-01-27 23:15:26 +0100 |
|---|---|---|
| committer | Xavier Ordoquy | 2015-01-27 23:15:26 +0100 |
| commit | 987880e13138a93d9cc0e44b7ed30297909f7b03 (patch) | |
| tree | 1925d91078eff41d05a8e9840c503b6117d41446 /tutorial/1-serialization | |
| parent | d8dbd8679080035de4e785a8e7b998fb01f4052b (diff) | |
| download | django-rest-framework-987880e13138a93d9cc0e44b7ed30297909f7b03.tar.bz2 | |
Update documentation
Diffstat (limited to 'tutorial/1-serialization')
| -rw-r--r-- | tutorial/1-serialization/index.html | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/tutorial/1-serialization/index.html b/tutorial/1-serialization/index.html index 2363f355..6782a94c 100644 --- a/tutorial/1-serialization/index.html +++ b/tutorial/1-serialization/index.html @@ -565,13 +565,13 @@ serializer.data <p>Our <code>SnippetSerializer</code> class is replicating a lot of information that's also contained in the <code>Snippet</code> model. It would be nice if we could keep our code a bit more concise.</p> <p>In the same way that Django provides both <code>Form</code> classes and <code>ModelForm</code> classes, REST framework includes both <code>Serializer</code> classes, and <code>ModelSerializer</code> classes.</p> <p>Let's look at refactoring our serializer using the <code>ModelSerializer</code> class. -Open the file <code>snippets/serializers.py</code> again, and edit the <code>SnippetSerializer</code> class.</p> +Open the file <code>snippets/serializers.py</code> again, and replace the <code>SnippetSerializer</code> class with the following.</p> <pre><code>class SnippetSerializer(serializers.ModelSerializer): class Meta: model = Snippet fields = ('id', 'title', 'code', 'linenos', 'language', 'style') </code></pre> -<p>One nice property that serializers have is that you can inspect all the fields in a serializer instance, by printing it's representation. Open the Django shell with <code>python manage.py shell</code>, then try the following:</p> +<p>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 <code>python manage.py shell</code>, then try the following:</p> <pre><code>>>> from snippets.serializers import SnippetSerializer >>> serializer = SnippetSerializer() >>> print(repr(serializer)) |
