Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.50 KB | None | 0 0
  1.     def save_lessons(self, textbook, upload_file):
  2.         zipped_list = self.parse(upload_file)
  3.  
  4.         for tup in zipped_list:
  5.  
  6.             title = tup[0]
  7.             text = tup[1]
  8.  
  9.             f = tempfile.NamedTemporaryFile()
  10.             f.write(text)
  11.  
  12.             file_object = File(f)
  13.  
  14.             f.seek(0)
  15.  
  16.             lesson = Lesson(title=title, file=file_object, textbook=textbook)
  17.             print(title)
  18.             print(file_object)
  19.             lesson.save()
  20.             f.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement