From b71e6b596f6ca352974a611af8eb74ed00a44c6a Mon Sep 17 00:00:00 2001 From: auvipy Date: Thu, 15 Oct 2015 14:16:35 +0600 Subject: [PATCH 1/3] removed south migrations --- rest_framework/authtoken/south_migrations/0001_initial.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 rest_framework/authtoken/south_migrations/0001_initial.py diff --git a/rest_framework/authtoken/south_migrations/0001_initial.py b/rest_framework/authtoken/south_migrations/0001_initial.py new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/rest_framework/authtoken/south_migrations/0001_initial.py @@ -0,0 +1 @@ + From fa93d790263e64a8414c9652e6ec1a668910530d Mon Sep 17 00:00:00 2001 From: auvipy Date: Thu, 15 Oct 2015 14:17:56 +0600 Subject: [PATCH 2/3] removed south_migrations directory --- rest_framework/authtoken/south_migrations/0001_initial.py | 1 - 1 file changed, 1 deletion(-) delete mode 100644 rest_framework/authtoken/south_migrations/0001_initial.py diff --git a/rest_framework/authtoken/south_migrations/0001_initial.py b/rest_framework/authtoken/south_migrations/0001_initial.py deleted file mode 100644 index 8b1378917..000000000 --- a/rest_framework/authtoken/south_migrations/0001_initial.py +++ /dev/null @@ -1 +0,0 @@ - From d64bfef56af2d098770c2216770c311a06e03127 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Padilla?= Date: Fri, 23 Oct 2015 09:58:06 -0400 Subject: [PATCH 3/3] Map all supported FilePathField options --- rest_framework/utils/field_mapping.py | 15 +++++++++++++++ tests/test_model_serializer.py | 2 ++ 2 files changed, 17 insertions(+) diff --git a/rest_framework/utils/field_mapping.py b/rest_framework/utils/field_mapping.py index 24fccec8c..05dd2e379 100644 --- a/rest_framework/utils/field_mapping.py +++ b/rest_framework/utils/field_mapping.py @@ -106,6 +106,21 @@ def get_field_kwargs(field_name, model_field): isinstance(model_field, models.TextField)): kwargs['allow_blank'] = True + if isinstance(model_field, models.FilePathField): + kwargs['path'] = model_field.path + + if model_field.match is not None: + kwargs['match'] = model_field.match + + if model_field.recursive is not False: + kwargs['recursive'] = model_field.recursive + + if model_field.allow_files is not True: + kwargs['allow_files'] = model_field.allow_files + + if model_field.allow_folders is not False: + kwargs['allow_folders'] = model_field.allow_folders + if model_field.choices: # If this model field contains choices, then return early. # Further keyword arguments are not valid. diff --git a/tests/test_model_serializer.py b/tests/test_model_serializer.py index c9b2d313e..93a69fe4b 100644 --- a/tests/test_model_serializer.py +++ b/tests/test_model_serializer.py @@ -67,6 +67,7 @@ class RegularFieldsModel(models.Model): time_field = models.TimeField() url_field = models.URLField(max_length=100) custom_field = CustomField() + file_path_field = models.FilePathField(path='/tmp/') def method(self): return 'method' @@ -165,6 +166,7 @@ class TestRegularFieldMappings(TestCase): time_field = TimeField() url_field = URLField(max_length=100) custom_field = ModelField(model_field=) + file_path_field = FilePathField(path='/tmp/') """) self.assertEqual(unicode_repr(TestSerializer()), expected)