Django REST framework¶
کلاسهای مجوز، mixinهای serializer و viewsetها - هر کدام به تنهایی، روی هر view در DRF. توضیحهای زیر از خود کد خوانده میشوند، و مثل کد به انگلیسیاند.
ModelPolicyPermission
¶
PolicyPermission
¶
Bases: BasePermission
Asks the policy the view names in policy.
policy_for_view
classmethod
¶
The policy asked for view, read off its class - None when it names none.
refuse_writes
staticmethod
¶
A 400 naming every field the request sends that the person may not
write - by the model field each name writes: decision, sent to a
serializer whose field has source='status', is the status.
ProtectedFieldsSerializerMixin
¶
Leaves out, locks and refuses what the person may not read or write.
protected_for
property
¶
Whose serializer this is: the request's person, or context['user'].
build_nested_field
¶
A serializer depth makes for a related row protects that row's fields too.
create
¶
The row made, refused and undone when it is outside the scope of create.
update
¶
The row changed, refused and undone when it is moved out of the rows reached.
many_init
classmethod
¶
A list of these, saved in one transaction: a row refused undoes the rows before it.
protected_serializer
cached
¶
serializer_class with ProtectedFieldsSerializerMixin - made once
per class. A serializer of no model is returned as it is: its writes are
the permission class's to guard.
ScopedModelViewSet
¶
Bases: ProtectedSerializerMixin, ScopedQuerySetMixin, ModelViewSet
A ModelViewSet asking the model's policy, over the rows the person reaches.
ScopedReadOnlyViewSet
¶
Bases: ProtectedSerializerMixin, ScopedQuerySetMixin, ReadOnlyModelViewSet
A ReadOnlyModelViewSet asking the model's policy, over the rows the person reaches.