MCPcopy
hub / github.com/django/django / with_perm

Method with_perm

django/contrib/auth/models.py:219–244  ·  view source on GitHub ↗
(
        self, perm, is_active=True, include_superusers=True, backend=None, obj=None
    )

Source from the content-addressed store, hash-verified

217 acreate_superuser.alters_data = True
218
219 def with_perm(
220 self, perm, is_active=True, include_superusers=True, backend=None, obj=None
221 ):
222 if backend is None:
223 backends = auth.get_backends()
224 if len(backends) == 1:
225 backend = backends[0]
226 else:
227 raise ValueError(
228 "You have multiple authentication backends configured and "
229 "therefore must provide the `backend` argument."
230 )
231 elif not isinstance(backend, str):
232 raise TypeError(
233 "backend must be a dotted import path string (got %r)." % backend
234 )
235 else:
236 backend = auth.load_backend(backend)
237 if hasattr(backend, "with_perm"):
238 return backend.with_perm(
239 perm,
240 is_active=is_active,
241 include_superusers=include_superusers,
242 obj=obj,
243 )
244 return self.none()
245
246
247# A few helper functions for common logic between User and AnonymousUser.

Callers

nothing calls this directly

Calls 1

noneMethod · 0.80

Tested by

no test coverage detected