django-url-filter
django-url-filter copied to clipboard
Filters against decimals are removed if the query decimal is too long
It seems that if the decimal in the url is not within the specifications given in the model definition, then the filter fails and returns everything.
class Test(models.Model):
my_number = models.DecimalField(max_digits=2, decimal_places=1)
Test.objects.create(my_number=1.5)
1 result: /test/ /test/?my_number__gte=1 /test/?my_number__gte=1.0 /test/?my_number__gte=.0 /test/?my_number__gte=2.00 <- incorrect /test/?my_number__gte=20 <- incorrect
0 results: /test/?my_number__gte=2 /test/?my_number__gte=2.0
That's expected. You can change the strictness mode on the filterset to raise errors vs default behavior of dropping the filter criteria.
No option for the filter to work normally? These filters work perfectly fine in the django ORM.
you can always overwrite the filterset filter/field to be less strict. making less strong validations seems like could be dangerous