APIView¶
Base APIView classes with serializer and pagination helpers. See the APIView guide for the dispatch loop and helper method surface.
APIView ¶
Bases: APIViewHelpersMixin, APIView
DRF APIView plus restflow response and serializer helpers.
Sync view base. Use restflow.views.AsyncAPIView for async dispatch.
class UserView(APIView):
serializer_class = UserSer
pagination_class = PageNumberPagination
def get(self, request):
return self.paginated_response(User.objects.all())
def post(self, request):
ser = self.validated_serializer()
user = ser.save()
return self.serialized_response(user, status=201)
AsyncAPIView ¶
Bases: APIViewHelpersMixin, APIView
APIView whose dispatch loop is async.
Adds an async dispatch and a*-prefixed surface (ainitial, ahandle_exception, avalidated_serializer, aserialized_response, apaginated_response) on top of DRF's APIView.
ainitial
async
¶
Runs anything that needs to occur prior to calling the method handler.
aperform_authentication
async
¶
Performs authentication on the incoming request.
acheck_permissions
async
¶
Checks if the request should be permitted, raising on failure.
acheck_object_permissions
async
¶
Checks if the request should be permitted for a given object.
ahandle_exception
async
¶
Handles any exception that occurs, by returning an appropriate response, or re-raising the error.
afinalize_response
async
¶
Returns the final response object after any processing.
avalidated_serializer
async
¶
Returns a serializer with the request data validated, awaiting ais_valid when available.
aserialized_response
async
¶
aserialized_response(
instance,
*,
many=False,
status=status.HTTP_200_OK,
serializer_class=None,
post_fetches=None,
headers=None,
)
Returns a Response containing the serialized instance, awaiting any post-fetch helpers.
apaginated_response
async
¶
apaginated_response(
queryset,
*,
serializer_class=None,
pagination_class=None,
post_fetches=None,
headers=None,
)
Returns a paginated Response for the given queryset, using async paginator hooks when available.