Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-rest-framework
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
django-rest-framework
Commits
df29641f
Commit
df29641f
authored
Dec 17, 2014
by
Tom Christie
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2300 from maryokhin/master
Docs/tutorial import fixes
parents
41810863
eeb6e340
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
5 deletions
+5
-5
docs/api-guide/serializers.md
+5
-3
docs/tutorial/1-serialization.md
+0
-2
No files found.
docs/api-guide/serializers.md
View file @
df29641f
...
@@ -22,11 +22,13 @@ The serializers in REST framework work very similarly to Django's `Form` and `Mo
...
@@ -22,11 +22,13 @@ The serializers in REST framework work very similarly to Django's `Form` and `Mo
Let's start by creating a simple object we can use for example purposes:
Let's start by creating a simple object we can use for example purposes:
from datetime import datetime
class Comment(object):
class Comment(object):
def __init__(self, email, content, created=None):
def __init__(self, email, content, created=None):
self.email = email
self.email = email
self.content = content
self.content = content
self.created = created or datetime.
datetime.
now()
self.created = created or datetime.now()
comment = Comment(email='leila@example.com', content='foo bar')
comment = Comment(email='leila@example.com', content='foo bar')
...
@@ -61,10 +63,10 @@ At this point we've translated the model instance into Python native datatypes.
...
@@ -61,10 +63,10 @@ At this point we've translated the model instance into Python native datatypes.
Deserialization is similar. First we parse a stream into Python native datatypes...
Deserialization is similar. First we parse a stream into Python native datatypes...
from
StringIO import String
IO
from
django.utils.six import Bytes
IO
from rest_framework.parsers import JSONParser
from rest_framework.parsers import JSONParser
stream =
String
IO(json)
stream =
Bytes
IO(json)
data = JSONParser().parse(stream)
data = JSONParser().parse(stream)
...then we restore those native datatypes into a dictionary of validated data.
...then we restore those native datatypes into a dictionary of validated data.
...
...
docs/tutorial/1-serialization.md
View file @
df29641f
...
@@ -161,8 +161,6 @@ At this point we've translated the model instance into Python native datatypes.
...
@@ -161,8 +161,6 @@ At this point we've translated the model instance into Python native datatypes.
Deserialization is similar. First we parse a stream into Python native datatypes...
Deserialization is similar. First we parse a stream into Python native datatypes...
# This import will use either `StringIO.StringIO` or `io.BytesIO`
# as appropriate, depending on if we're running Python 2 or Python 3.
from django.utils.six import BytesIO
from django.utils.six import BytesIO
stream = BytesIO(content)
stream = BytesIO(content)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment