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
877e964d
Commit
877e964d
authored
Aug 03, 2015
by
Tom Christie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't need to support Django 1.4 with FilePathField.
parent
8d7c0a84
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
21 deletions
+5
-21
rest_framework/compat.py
+0
-18
rest_framework/fields.py
+5
-3
No files found.
rest_framework/compat.py
View file @
877e964d
...
...
@@ -257,21 +257,3 @@ def set_rollback():
else
:
# transaction not managed
pass
def
get_filepathfield
(
path
,
match
=
None
,
recursive
=
False
,
allow_files
=
True
,
allow_folders
=
False
,
required
=
None
):
"""Create proper Django FilePathField with allowed kwargs."""
if
django
.
VERSION
<
(
1
,
5
):
# django field doesn't have allow_folders, allow_files kwargs
field
=
DjangoFilePathField
(
path
,
match
=
match
,
recursive
=
recursive
,
required
=
required
)
else
:
field
=
DjangoFilePathField
(
path
,
match
=
match
,
recursive
=
recursive
,
allow_files
=
allow_files
,
allow_folders
=
allow_folders
,
required
=
required
)
return
field
rest_framework/fields.py
View file @
877e964d
...
...
@@ -12,6 +12,7 @@ from django.conf import settings
from
django.core.exceptions
import
ValidationError
as
DjangoValidationError
from
django.core.exceptions
import
ObjectDoesNotExist
from
django.core.validators
import
RegexValidator
,
ip_address_validators
from
django.forms
import
FilePathField
as
DjangoFilePathField
from
django.forms
import
ImageField
as
DjangoImageField
from
django.utils
import
six
,
timezone
from
django.utils.dateparse
import
parse_date
,
parse_datetime
,
parse_time
...
...
@@ -23,7 +24,7 @@ from rest_framework import ISO_8601
from
rest_framework.compat
import
(
EmailValidator
,
MaxLengthValidator
,
MaxValueValidator
,
MinLengthValidator
,
MinValueValidator
,
OrderedDict
,
URLValidator
,
duration_string
,
get_filepathfield
,
parse_duration
,
unicode_repr
,
unicode_to_repr
parse_duration
,
unicode_repr
,
unicode_to_repr
)
from
rest_framework.exceptions
import
ValidationError
from
rest_framework.settings
import
api_settings
...
...
@@ -713,8 +714,9 @@ class FilePathField(CharField):
allow_folders
=
False
,
required
=
None
,
**
kwargs
):
super
(
FilePathField
,
self
)
.
__init__
(
**
kwargs
)
# create field and get options to avoid code duplication
field
=
get_filepathfield
(
# Defer to Django's FilePathField implmentation to get the
# valid set of choices.
field
=
DjangoFilePathField
(
path
,
match
=
match
,
recursive
=
recursive
,
allow_files
=
allow_files
,
allow_folders
=
allow_folders
,
required
=
required
)
...
...
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