Skip to content

Better ViewSet Mixins

Compare
Choose a tag to compare
@banesullivan banesullivan released this 10 Apr 21:18
· 103 commits to main since this release

This release has breaking changes

There are now 4 ViewSet mixin classes for use with both detail and non-detail viewsets in DRF.

The following are the provided mixin classes and their use case:

  • LargeImageMixin: for use with a standard, non-detail ViewSet. Users must implement get_path()
  • LargeImageDetailMixin: for use with a detail viewset like GenericViewSet. Users must implement get_path()
  • LargeImageFileDetailMixin: (most commonly used) for use with a detail viewset like GenericViewSet where the associated model has a FileField storing the image data.
  • LargeImageVSIFileDetailMixin: (geospatial) for use with a detail viewset like GenericViewSet where the associated model has a FileField storing the image data that is intended to be read with GDAL. This will access the data over GDAL's Virtual File System interface (a VSI path).

Most users will want to use LargeImageFileDetailMixin

Other changes:

  • Style parameters can now be included as a JSON blob in the request body following the format specified by large-image
  • The thumbnail, tile, and region endpoints now each have .png, .jpeg, and .tif variants where appropriate
  • DRF ValidationErrors are raised for user-caused API errors (return 400 status on endpoint)
  • More usage examples