Skip to content

Django's views

Mixins for Django's class-based views, and a decorator for a function view.

ScopedQuerySetMixin

Narrows the view's queryset to the rows the person reaches for its action.

form_valid

form_valid(form: Any) -> HttpResponseBase

Django's CreateView and UpdateView: the row saved stays within the scope. Its DeleteView: the rows a cascade takes are deletable too.

perform_destroy

perform_destroy(instance: Any) -> None

DRF's DestroyModelMixin: nothing a cascade takes is outside the delete scope.

perform_create

perform_create(serializer: Any) -> None

DRF's CreateModelMixin: the row made is one the person may make.

perform_update

perform_update(serializer: Any) -> None

DRF's UpdateModelMixin: the row is not edited out of the rows the person reaches.

require_written_within_scope

require_written_within_scope(obj: object, *, creating: bool) -> None

obj - or each row of it, for a list saved at once - within the action's scope.

PolicyRequiredMixin

Bases: AccessMixin

Asks the policy whether the person may do the view's action.

resolved_action classmethod

resolved_action() -> str | None

policy_action, or the one read off the view, or None.

resolved_policy classmethod

resolved_policy() -> BasePolicy | None

policy, or the policy of the view's model, or None.

configuration_errors classmethod

configuration_errors() -> list[str]

What stops this view from asking a policy - for the system check too.

ProtectedFieldsViewMixin

Builds the view's form for the person, and tells its template which fields they may see.

policy_required

policy_required(policy: BasePolicy, action: str) -> Callable[[ViewT], ViewT]

Let the view run only for somebody policy allows action.