Skip to content

Commit 44d4d24

Browse files
authored
made magic_file_path only apply in windows
1 parent d93fd30 commit 44d4d24

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

validatedfile/fields.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from django.template.defaultfilters import filesizeformat
44
from django.utils.translation import ugettext as _
55
from django.conf import settings
6+
import os
67

78
import magic
89

@@ -20,9 +21,10 @@ def clean(self, *args, **kwargs):
2021

2122
if self.content_types:
2223
uploaded_content_type = getattr(file, 'content_type', '')
23-
24+
25+
# magic_file_path used only for Windows.
2426
magic_file_path = getattr(settings, "MAGIC_FILE_PATH", None)
25-
if magic_file_path:
27+
if magic_file_path and os.name == 'nt':
2628
mg = magic.Magic(mime=True, magic_file=magic_file_path)
2729
else:
2830
mg = magic.Magic(mime=True)

0 commit comments

Comments
 (0)