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
8cf37449
Commit
8cf37449
authored
Jan 05, 2015
by
Tom Christie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure no invalid min_length/min_value/max_value arguments. Closes #2369.
parent
f8e310fd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
3 deletions
+8
-3
rest_framework/utils/field_mapping.py
+8
-3
No files found.
rest_framework/utils/field_mapping.py
View file @
8cf37449
...
...
@@ -10,6 +10,11 @@ from rest_framework.validators import UniqueValidator
import
inspect
NUMERIC_FIELD_TYPES
=
(
models
.
IntegerField
,
models
.
FloatField
,
models
.
DecimalField
)
class
ClassLookupDict
(
object
):
"""
Takes a dictionary with classes as keys.
...
...
@@ -119,7 +124,7 @@ def get_field_kwargs(field_name, model_field):
validator
.
limit_value
for
validator
in
validator_kwarg
if
isinstance
(
validator
,
validators
.
MinLengthValidator
)
),
None
)
if
min_length
is
not
None
:
if
min_length
is
not
None
and
isinstance
(
model_field
,
models
.
CharField
)
:
kwargs
[
'min_length'
]
=
min_length
validator_kwarg
=
[
validator
for
validator
in
validator_kwarg
...
...
@@ -132,7 +137,7 @@ def get_field_kwargs(field_name, model_field):
validator
.
limit_value
for
validator
in
validator_kwarg
if
isinstance
(
validator
,
validators
.
MaxValueValidator
)
),
None
)
if
max_value
is
not
None
:
if
max_value
is
not
None
and
isinstance
(
model_field
,
NUMERIC_FIELD_TYPES
)
:
kwargs
[
'max_value'
]
=
max_value
validator_kwarg
=
[
validator
for
validator
in
validator_kwarg
...
...
@@ -145,7 +150,7 @@ def get_field_kwargs(field_name, model_field):
validator
.
limit_value
for
validator
in
validator_kwarg
if
isinstance
(
validator
,
validators
.
MinValueValidator
)
),
None
)
if
min_value
is
not
None
:
if
min_value
is
not
None
and
isinstance
(
model_field
,
NUMERIC_FIELD_TYPES
)
:
kwargs
[
'min_value'
]
=
min_value
validator_kwarg
=
[
validator
for
validator
in
validator_kwarg
...
...
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