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
-
pip install drf-orderwcast; -
Add
drf_orderwcastin INSTALLED_APPS ofsettings.pyfile.
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c16f2899c85c848e70d993d8bfcd42fa148c4a8516de22d89893cc0748aaff3d
|
|
| MD5 |
78a29e771f3570c21a82572c684b4ee0
|
|
| BLAKE2b-256 |
95009e0fa81f289a1f695cecec812fb1ab217e67f40cb227b5df09a44c1c72c3
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1694e104358b8cf8b97f2cf7374926c39dba56446f45fe6e29d29350774ab16b
|
|
| MD5 |
fd3b7bdff0864fcfab8f697fd350ab02
|
|
| BLAKE2b-256 |
5487d18fd8fed6f6ae292ea9c1a6cd6baca1d78b9da0a45ebe3b277ba24376c6
|