fix FilePathField kwargs for django < 1.5

This commit is contained in:
Aider Ibragimov 2015-03-03 16:58:04 +03:00
parent 04cc1964bd
commit e5d95e319e

View File

@ -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,7 +666,14 @@ 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
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( field = DjangoFilePathField(
path, match=match, recursive=recursive, allow_files=allow_files, path, match=match, recursive=recursive, allow_files=allow_files,
allow_folders=allow_folders, required=required allow_folders=allow_folders, required=required