允许is_staff = False访问特定页面Django

时间:2018-12-19 09:19:31

标签: django

我具有更改密码功能,该功能仅允许INFO:oauth2client.transport:Refreshing due to a 401 (attempt 1/2) INFO:oauth2client.client:Refreshing access_token INFO:root:2018-12-19T09:13:09.510Z: JOB_MESSAGE_ERROR: java.util.concurrent.ExecutionException: org.apache.beam.vendor.grpc.v1.io.grpc.StatusRuntimeException: CANCELLED: cancelled before receiving half close java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:357) java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1895) org.apache.beam.sdk.util.MoreFutures.get(MoreFutures.java:57) = is_staff访问,不允许False = is_staff查看此页面。

有没有办法做到这一点?

我只找到True,但这是给工作人员的。

staff_member_requird

1 个答案:

答案 0 :(得分:2)

您可以将user_passes_test装饰器与任意函数一起使用。所以:

@user_passes_test(lambda u: not u.is_staff)
def change_password(request):
   ...
相关问题