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
1e53eb0a
Commit
1e53eb0a
authored
Sep 11, 2014
by
Tom Christie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DecimalFields should still be quantized even without coerce_to_string
parent
040bfcc0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
3 deletions
+5
-3
rest_framework/fields.py
+5
-3
No files found.
rest_framework/fields.py
View file @
1e53eb0a
...
@@ -486,9 +486,6 @@ class DecimalField(Field):
...
@@ -486,9 +486,6 @@ class DecimalField(Field):
return
value
return
value
def
to_primative
(
self
,
value
):
def
to_primative
(
self
,
value
):
if
not
self
.
coerce_to_string
:
return
value
if
isinstance
(
value
,
decimal
.
Decimal
):
if
isinstance
(
value
,
decimal
.
Decimal
):
context
=
decimal
.
getcontext
()
.
copy
()
context
=
decimal
.
getcontext
()
.
copy
()
context
.
prec
=
self
.
max_digits
context
.
prec
=
self
.
max_digits
...
@@ -496,7 +493,12 @@ class DecimalField(Field):
...
@@ -496,7 +493,12 @@ class DecimalField(Field):
decimal
.
Decimal
(
'.1'
)
**
self
.
decimal_places
,
decimal
.
Decimal
(
'.1'
)
**
self
.
decimal_places
,
context
=
context
context
=
context
)
)
if
not
self
.
coerce_to_string
:
return
quantized
return
'{0:f}'
.
format
(
quantized
)
return
'{0:f}'
.
format
(
quantized
)
if
not
self
.
coerce_to_string
:
return
value
return
'
%.*
f'
%
(
self
.
max_decimal_places
,
value
)
return
'
%.*
f'
%
(
self
.
max_decimal_places
,
value
)
...
...
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