我有一个问题,删除用户在视图中,甚至在shell中的权限。我来解释一下我的问题:
我在壳里做了测试:
org = Organisateur.objects.get(user__username__contains="ghj")
content_type = ContentType.objects.get_for_model(Tournoi)
图诺是一个模特的名字
^{pr2}$但当我写下:
org.user.has_perm('inscription.ecriture_Palaiseau')`
它返回True
但当我重写:
org = Organisateur.objects.get(user__username__contains="ghj")
org.user.has_perm('inscription.ecriture_Palaiseau')`
它返回False
真的很奇怪。为什么会这样工作?在
在我看来,即使我写了以下内容,权限也不会被删除:
org = Organisateur.objects.get(user__username__contains="ghj")
(删除权限后,用户仍然拥有权限)
我要做的是从一个用户中删除一个权限,然后立即向同一个用户添加另一个权限。 但每次我这么做,用户仍然有“删除权限”。。。。。。在
非常感谢
我期待着很快收到你们的来信。在
此行为是预期的,因为权限已缓存。来自Django文档:
相关问题 更多 >
编程相关推荐