Django 用户特定文件(浏览、下载)
我遇到过这样的情况:我有一个 Django 应用程序,用户在其中注册帐户。用户每个月都会生成一堆 Excel 文件。这些文件目前只是在服务器上生成并存储在文件系统中的文件,现在不属于任何模型定义的一部分,尽管我可能可以更改它以将它们定义在模型中,并与用户权限一起使用。
该应用程序按预期工作,但我一直困惑于如何让用户浏览和下载自己生成的文件,同时禁止访问其他用户的文件。
我正在查看 django-filer,但想知道以前是否有人遇到过这种情况?
I have a situation where I have a Django app where users sign up for an account. The users generate a bunch of Excel files each month. These files are currently simply files generated on the server and stored in the filesystem, and are not part of any model definition right now, though I could probably change that to have them defined in a model, and use together with user permissions.
The app is working as expected, but I am stuck on how to let users browse and download their own generated files, while disallowing access to other users' files.
I was looking at django-filer, but am wondering if anybody has met with this situation before?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要一个
FileField
、一个到User
或Group
的 FK 或 M2M,以及 这个。You'll want a
FileField
, a FK or M2M toUser
orGroup
, and this.