django를 통해 여러 파일을 업로드하는 방법을 알고 있지만, 거기에 하위 폴더가있는 경우 폴더를 업로드 할 때 문제가 있습니다. 장고 하위 폴더를받을 수 없습니다. 그 이유는 브라우저가 '.'을 사용했기 때문입니다. 폴더를 나타 내기 위해 django는 파싱 할 수 없으며 파싱을 중지합니다. 그것을 고치기위한 우아한 방법이 있습니까?django 어떻게 폴더를 업로드
파이썬 코드 :
def uploader_single(request):
data = {}
if request.method == 'POST':
if True:
for afile in request.FILES.getlist('file'):
new_file = UploadFileSingle(file = afile)
new_file.save()
return HttpResponseRedirect('')
else:
print "form is not valid"
return HttpResponseRedirect('')
else:
print 'not post'
파이썬 코드 :
class UploadFileSingle(models.Model):
file = models.FileField(upload_to='files/%Y/%m/%d', models.FilePath)
uploaded_at = models.DateTimeField(auto_now_add=True)
models.FilePathField.recursive = True
models.FilePathField.allow_folders = True
updated_at = models.DateTimeField(auto_now=True)
def some_folder = FilePathField(path='some_path', recursive=True, allow_files=True, allow_folders=True,)'
HTML 코드 :
<input type="file" name="file" multiple = "true" webkitdirectory="true" directory = "true"/>
대단히 감사합니다. 하지만 내 사건에 필터를 정확히 적용 할 수있는 방법을 설명해 주시겠습니까? 고맙습니다. – Tengerye
django 필터가 그렇게 할 수 없습니다. 내 결론은 장고 아직 할 수 없다는 것입니다. – Tengerye
질문과 관련 없음 –