1.文件上传 Models 设计 class Upload_File(models.Model): image = models.FileField(upload_to='file/%Y/%m',default = 'image/default.png',max_length=100) add_time = models.DateTimeField(auto_now_add=True,verbose_name='添加时间') forms 设计 from django import forms f…
代码: from django.http import StreamingHttpResponse def big_file_download(request): # do something... def file_iterator(file_name, chunk_size=): with open(file_name) as f: while True: c = f.read(chunk_size) if c: yield c else: break the_file_name = "bi…
from django.http import StreamingHttpResponse#文件流 def big_file_download(request): # do something... def file_iterator(file_name, chunk_size=512): with open(file_name,'rb') as f: while True: c = f.read(chunk_size) if c: yield c else: break the_file_na…