Django 用户特定文件(浏览、下载)

发布于 2024-11-14 22:00:08 字数 246 浏览 8 评论 0原文

我遇到过这样的情况:我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

煮茶煮酒煮时光 2024-11-21 22:00:08

您需要一个 FileField、一个到 UserGroup 的 FK 或 M2M,以及 这个

You'll want a FileField, a FK or M2M to User or Group, and this.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文