update tutorial - serialization

This commit is contained in:
kst6294 2022-01-06 15:44:35 +09:00
parent 5b2abbed25
commit d7968b78e7

View File

@ -45,7 +45,7 @@ We'll need to add our new `snippets` app and the `rest_framework` app to `INSTAL
INSTALLED_APPS = [ INSTALLED_APPS = [
... ...
'rest_framework', 'rest_framework',
'snippets.apps.SnippetsConfig', 'snippets',
] ]
Okay, we're ready to roll. Okay, we're ready to roll.
@ -77,7 +77,7 @@ For the purposes of this tutorial we're going to start by creating a simple `Sni
We'll also need to create an initial migration for our snippet model, and sync the database for the first time. We'll also need to create an initial migration for our snippet model, and sync the database for the first time.
python manage.py makemigrations snippets python manage.py makemigrations snippets
python manage.py migrate python manage.py migrate snippets
## Creating a Serializer class ## Creating a Serializer class
@ -206,8 +206,8 @@ One nice property that serializers have is that you can inspect all the fields i
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:
* An automatically determined set of fields. - An automatically determined set of fields.
* Simple default implementations for the `create()` and `update()` methods. - Simple default implementations for the `create()` and `update()` methods.
## Writing regular Django views using our Serializer ## Writing regular Django views using our Serializer
@ -307,8 +307,8 @@ Quit out of the shell...
Validating models... Validating models...
0 errors found 0 errors found
Django version 1.11, using settings 'tutorial.settings' Django version 4.0,1 using settings 'tutorial.settings'
Development server is running at http://127.0.0.1:8000/ Starting Development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C. Quit the server with CONTROL-C.
In another terminal window, we can test the server. In another terminal window, we can test the server.