- lesson = cls(slug=slug)
-
- lesson.attachment_set.all().delete()
- for att_name, att_file in infile.attachments.items():
- try:
- slug, ext = att_name.rsplit('.', 1)
- except ValueError:
- slug, ext = att_name, ''
- attachment = lesson.attachment_set.create(slug=slug, ext=ext)
- attachment.file.save(att_name, ContentFile(att_file.get_string()))