在接下来的Django manage.py
shell 会话中,为什么我在为该用户执行新查询之前看不到我添加到用户对象的权限?
In [16]: john = User.objects.create_user(username='john')
In [17]: john
Out[17]: <User: john>
In [18]: john.get_all_permissions()
Out[18]: set([])
In [19]: john.user_permissions.add(Permission.objects.get(codename='add_user'))
In [20]: john.get_all_permissions()
Out[20]: set([]) <== I expected to see the new permission here. Why not?
In [21]: john = User.objects.get(username='john')
In [22]: john.get_all_permissions()
Out[22]: set([u'auth.add_user'])