linux - 通过django访问*nix文件系统

标签 linux django

我在 /home/user/project 中安装了一个 django 项目。并且在代码中有笔画,在文件系统中处理文件。如果我创建新目录 os.makedirs('crowdin_temp') 它是在 django 项目文件夹中创建的。如果我使用文件系统执行 os.system 命令(例如 os.system("rm mudin_temp/"+ file_name) ),则项目目录中的文件是可见的。这让我感觉只有 django 项目文件夹是可见的。是否可以处理项目文件夹之外的文件? (例如在 /home/user/ 目录中)

最佳答案

为什么不指定完整路径?

$ ./manage.py shell
>>> import os
>>> os.makedirs('/tmp/temp')
>>> os.system('touch /tmp/temp/somefile')
0
>>> os.system('rm /tmp/temp/somefile')
0

关于linux - 通过django访问*nix文件系统,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31782117/

相关文章:

python - Django 内联表单集不会这样做

Django 1.6 + Celery 3.1 = 类型错误 : 'Settings' object has no attribute '__getitem__'

linux - 使用 mmap 访问 PCI-e 内存空间

linux - systemctl start nginx 和 systemctl start nginx.service 有什么区别?

linux - 对于高级用户来说,有哪些优秀的 Linux/Unix 书籍?

python - 如何在 Django 中设置 session 永不过期

linux - 查找一个文件中包含的行字符串并将其替换为 shell 脚本中的第二个文件

c++ - callgrind 关闭仪器后速度变慢

python - 如何使用 Django 在模型对象中分配项目?

django - 属性错误 : module 'django.db.models' has no attribute 'model'