Django: How to allow a Suspicious File Operation / copy a file

后端 未结 4 569
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-04 01:54

I want to do a SuspiciousFileOperation which django disallows by default.

I am writing a command (to run via manage.py importfiles) to impo

4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-04 02:38

    Check if there is slash before your filepath

    file_item = models.FileField(upload_to=content_file_name)
    
    
    def content_file_name(username, filename):
        return '/'.join(['content', username, filename])
    

    Note here "content" not "/content". That was the problem for me.

提交回复
热议问题