def handle_uploaded_attachment(self,model_object,attachment_file,attached_by,title=None,summary=None): if title is None: title = attachment_file.name if summary is None: summary = attachment_file.name object_type = ContentType.objects.get_for_model(model_object) object_id = model_object.id self.content_type = object_type self.object_id = object_id self.title = title self.summary = summary self.attached_by = attached_by self.mimetype = attachment_file.content_type file_path =os.path.join(ATTACHMENT_DIR, randomfilename(attachment_file.name)) self.file.save(file_path, attachment_file,save=False) self.save()
def handle_uploaded_attachment(self, model_object, attachment_file, attached_by, title=None, summary=None): if title is None: title = attachment_file.name if summary is None: summary = attachment_file.name object_type = ContentType.objects.get_for_model(model_object) object_id = model_object.id self.content_type = object_type self.object_id = object_id self.title = title self.summary = summary self.attached_by = attached_by self.mimetype = attachment_file.content_type file_path = os.path.join(ATTACHMENT_DIR, randomfilename(attachment_file.name)) self.file.save(file_path, attachment_file, save=False) self.save()
def get_storage_path(instance, filename): return os.path.join(PHOTOLOGUE_DIR, 'photos', randomfilename(filename))
def save_uploaded_file(self, memoryfiledfile): file_path = os.path.join(ATTACHMENT_DIR, randomfilename(memoryfiledfile.name)) self.file.save(file_path, memoryfiledfile)
def save_uploaded_file(self,memoryfiledfile): file_path =os.path.join(ATTACHMENT_DIR, randomfilename(memoryfiledfile.name)) self.file.save(file_path, memoryfiledfile)