![]() Note that if your API doesn't include any object level permissions, you may optionally exclude the self.check_object_permissions, and simply return the object from the get_object_or_404 lookup. Self.check_object_permissions(self.request, obj) Obj = get_object_or_404(queryset, **filter) May be overridden to provide more complex behavior, such as object lookups based on more than one URL kwarg.įor field in self.multiple_lookup_fields: Defaults to using the lookup_field parameter to filter the base queryset. Returns an object instance that should be used for detail views. To get more information about n+1 problem and use cases of the mentioned methods refer to related section in django documentation. ![]() Note: If the serializer_class used in the generic view spans orm relations, leading to an n+1 problem, you could optimize your queryset in this method using select_related and prefetch_related. May be overridden to provide dynamic behavior, such as returning a queryset, that is specific to the user making the request. This method should always be used rather than accessing self.queryset directly, as self.queryset gets evaluated only once, and those results are cached for all subsequent requests. Defaults to returning the queryset specified by the queryset attribute. Returns the queryset that should be used for list views, and that should be used as the base for lookups in detail views. Defaults to the same value as the DEFAULT_FILTER_BACKENDS setting. filter_backends - A list of filter backend classes that should be used for filtering the queryset.Setting pagination_class=None will disable pagination on this view. Defaults to the same value as the DEFAULT_PAGINATION_CLASS setting, which is 'rest_'. pagination_class - The pagination class that should be used when paginating list results.The following attributes are used to control pagination when used with list views. If unset this defaults to using the same value as lookup_field. The URL conf should include a keyword argument corresponding to this value. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |