我在django视图中使用带有@permission_required
装饰器的django 1.11,postgres。问题是,对于任何视图,我都会得到2个额外的SQL查询-
1)SELECT ••• FROM "auth_permission" INNER JOIN "account_myuser_user_permissions" ON ...
2)SELECT ••• FROM "auth_permission" INNER JOIN "auth_group_permissions" ON ...
Django文档指出-
The ModelBackend caches permissions on the user object after the first time they need to be fetched for a permissions check.
我不明白为什么第一次不缓存权限,或者我丢失了什么?