Commit e5d95e31 by Aider Ibragimov

fix FilePathField kwargs for django < 1.5

parent 04cc1964
...@@ -23,6 +23,7 @@ import collections ...@@ -23,6 +23,7 @@ import collections
import copy import copy
import datetime import datetime
import decimal import decimal
import django
import inspect import inspect
import re import re
import uuid import uuid
...@@ -665,11 +666,18 @@ class FilePathField(CharField): ...@@ -665,11 +666,18 @@ class FilePathField(CharField):
def __init__(self, path, match=None, recursive=False, allow_files=True, def __init__(self, path, match=None, recursive=False, allow_files=True,
allow_folders=False, required=None, **kwargs): allow_folders=False, required=None, **kwargs):
super(FilePathField, self).__init__(**kwargs) super(FilePathField, self).__init__(**kwargs)
# create field and get options to avoid code duplication # create field and get options to avoid code duplication
field = DjangoFilePathField( if django.VERSION < (1, 5):
path, match=match, recursive=recursive, allow_files=allow_files, # django field doesn't have allow_folders, allow_files kwargs
allow_folders=allow_folders, required=required 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
)
self.choices = OrderedDict(field.choices) self.choices = OrderedDict(field.choices)
self.choice_strings_to_values = dict([ self.choice_strings_to_values = dict([
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment