Skip to content

Commit ef26fd2

Browse files
committed
fix #26: raise exception if the content read is empty or ''
1 parent 472a2a8 commit ef26fd2

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

django_excel/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ class ExcelMixin(webio.ExcelInput):
2525
def get_params(self, **keywords):
2626
extension = self.name.split(".")[-1]
2727
keywords['file_type'] = extension
28-
keywords['file_content'] = self.file.read()
28+
content = self.file.read()
29+
if content:
30+
keywords['file_content'] = content
31+
else:
32+
raise IOError("No content was uploaded.")
2933
return keywords
3034

3135
def save_to_database(self, model=None, initializer=None, mapdict=None,

0 commit comments

Comments
 (0)