django 管理站点 - 过滤用户可用的对象
我有属于某个“组”(公司类)的模型。我想添加用户,他们也属于一个组,并且应该能够编辑/管理/添加具有关联组成员身份的对象。
类似于:
class Company()
class Something()
company = ForeignKey(Company)
user Microsoft_admin
company = ForeignKey(Company)
并且该用户只能在管理界面中查看和编辑属于关联公司的对象。
怎样才能做到这一点呢?
I have models that belong to some 'group' (Company class). I want to add users, who will also belong to a one group and should be able to edit/manage/add objects with membership in associated group.
something like:
class Company()
class Something()
company = ForeignKey(Company)
user Microsoft_admin
company = ForeignKey(Company)
and this user should only see and edit objects belonging to associated Company in the Admin Interface.
How to acomplish that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
嘿,也许你可以这样做这个
hey, maybe you can do something like this
有几种不同的方法可以做到这一点。您正在寻找的神奇词是“行级权限”。搜索该内容和“Django”,您应该会找到您要查找的内容。
但超过某一点后,更容易提出自己的观点。这完全取决于您的用例以及您想要实现的目标。
There are a few different ways to do it. The magic words that you're looking for are "row level permissions". Search for that and "Django" and you should find what you're looking for.
Beyond a certain point though, it's easier to roll your own views. It all depends on your use case, and what exactly you're trying to achieve.
我想说这已经在 中得到了令人满意的回答如何在 Django admin 中实现全局隐式过滤器?
I'd say this has been satisfyingly answered in How can I implement a global, implicit filter in Django admin?