Skip to main content

A Django REST Framework OrderingFilter like class that handles sort with casting

Project description

drf-orderwcast

OrderingFilter subclass that applies functions before sorting the declared fields.

Installing

  1. pip install drf-orderwcast;

  2. Add drf_orderwcast in INSTALLED_APPS of settings.py file.

Using

Use inplace of OrderingFilter in views. Needs to tell the functions in a dictionary of field name and database functions.

views.py

from django.db.models.functions import Lower

from drf_orderwcast import OrderingWCastFilter


class FooListView(generics.ListAPIView):
    queryset = Foo.objects.all()
    serializer_class = FooSerializer
    filter_backends = (OrderingWCastFilter,)
    ordering_fields = ['name', 'email']
    ordering_cast = {'name': Lower('name')}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

drf_orderwcast-1.0.5.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

drf_orderwcast-1.0.5-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file drf_orderwcast-1.0.5.tar.gz.

File metadata

  • Download URL: drf_orderwcast-1.0.5.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.18

File hashes

Hashes for drf_orderwcast-1.0.5.tar.gz
Algorithm Hash digest
SHA256 c16f2899c85c848e70d993d8bfcd42fa148c4a8516de22d89893cc0748aaff3d
MD5 78a29e771f3570c21a82572c684b4ee0
BLAKE2b-256 95009e0fa81f289a1f695cecec812fb1ab217e67f40cb227b5df09a44c1c72c3

See more details on using hashes here.

File details

Details for the file drf_orderwcast-1.0.5-py3-none-any.whl.

File metadata

  • Download URL: drf_orderwcast-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 3.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.18

File hashes

Hashes for drf_orderwcast-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 1694e104358b8cf8b97f2cf7374926c39dba56446f45fe6e29d29350774ab16b
MD5 fd3b7bdff0864fcfab8f697fd350ab02
BLAKE2b-256 5487d18fd8fed6f6ae292ea9c1a6cd6baca1d78b9da0a45ebe3b277ba24376c6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page