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
d540f026
Commit
d540f026
authored
Aug 19, 2016
by
orf
Committed by
Tom Christie
Aug 19, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve Create to show the original exception traceback (#3508)
parent
a335309b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
3 deletions
+5
-3
rest_framework/serializers.py
+5
-3
No files found.
rest_framework/serializers.py
View file @
d540f026
...
...
@@ -12,6 +12,7 @@ response content is handled by parsers and renderers.
"""
from
__future__
import
unicode_literals
import
traceback
import
warnings
from
django.db
import
models
...
...
@@ -870,19 +871,20 @@ class ModelSerializer(Serializer):
try
:
instance
=
ModelClass
.
objects
.
create
(
**
validated_data
)
except
TypeError
as
exc
:
except
TypeError
:
tb
=
traceback
.
format_exc
()
msg
=
(
'Got a `TypeError` when calling `
%
s.objects.create()`. '
'This may be because you have a writable field on the '
'serializer class that is not a valid argument to '
'`
%
s.objects.create()`. You may need to make the field '
'read-only, or override the
%
s.create() method to handle '
'this correctly.
\n
Original exception
text was:
%
s.
'
%
'this correctly.
\n
Original exception
was:
\n
%
s
'
%
(
ModelClass
.
__name__
,
ModelClass
.
__name__
,
self
.
__class__
.
__name__
,
exc
tb
)
)
raise
TypeError
(
msg
)
...
...
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