Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
drf-replace-ordering-filter
Django Rest Framework OrderingFilter backend to replace field name in ordering params.
Readme
Django Rest Framework OrderingFilter backend to replace field name in ordering params.
This package is useful if you have custom hidden fields in you model to help with a better ordering.
You can user ReplaceFieldOrderingFilter
as a Default Filter Backend in Rest Framework setting or specifying in a certain APIView.
ReplaceFieldOrderingFilter
works in the same way as rest_framework.filters.OrderingFilter
, if you do not define fields in a View to be replaced.
First of all, add ReplaceFieldOrderingFilter
to DEFAULT_FILTER_BACKENDS in setting.py
file of your Django's project.
REST_FRAMEWORK = {
'DEFAULT_FILTER_BACKENDS': (
'drf_replace_ordering_filter.filters.ReplaceFieldOrderingFilter',
)
}
Lastly, in a view that you want to change some ordering filed to another, add the following attribute.
from rest_framework import views
class MyAPIView(views.APIView):
replace_ordering_fields = {
'field_to_be_replaced': 'new_field'
}
def get(self, request, *args, **kwargs):
pass
The second option is using ReplaceFieldOrderingFilter
only in a specfic view or viewset.
For example:
from drf_replace_ordering_filter.filters import ReplaceFieldOrderingFilter
from rest_framework import views
class MyAPIView(views.APIView):
filter_backends = (ReplaceFieldOrderingFilter,)
replace_ordering_fields = {
'field_to_be_replaced': 'new_field'
}
def get(self, request, *args, **kwargs):
pass
FAQs
Django Rest Framework OrderingFilter backend to replace field name in ordering params.
We found that drf-replace-ordering-filter demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.