-
-
Notifications
You must be signed in to change notification settings - Fork 629
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Docs: remove "Ordering Output" section from quickstart
- Loading branch information
Showing
1 changed file
with
0 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -524,37 +524,6 @@ Note that ``name`` will be automatically formatted as a :class:`String <marshmal | |
# No need to include 'uppername' | ||
additional = ("name", "email", "created_at") | ||
Ordering Output | ||
--------------- | ||
|
||
To maintain field ordering, set the ``ordered`` option to `True`. This will instruct marshmallow to serialize data to a `collections.OrderedDict`. | ||
|
||
.. code-block:: python | ||
from collections import OrderedDict | ||
from pprint import pprint | ||
from marshmallow import Schema, fields | ||
class UserSchema(Schema): | ||
first_name = fields.String() | ||
last_name = fields.String() | ||
email = fields.Email() | ||
class Meta: | ||
ordered = True | ||
u = User("Charlie", "Stones", "[email protected]") | ||
schema = UserSchema() | ||
result = schema.dump(u) | ||
assert isinstance(result, OrderedDict) | ||
pprint(result, indent=2) | ||
# OrderedDict([('first_name', 'Charlie'), | ||
# ('last_name', 'Stones'), | ||
# ('email', '[email protected]')]) | ||
Next Steps | ||
---------- | ||
|
||
|