mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Fixes #2895: Fix filtering of nullable character fields
This commit is contained in:
@ -4,6 +4,7 @@ v2.5.7 (FUTURE)
|
||||
|
||||
* [#2888](https://github.com/digitalocean/netbox/issues/2888) - Correct foreground color of device roles in rack elevations
|
||||
* [#2893](https://github.com/digitalocean/netbox/issues/2893) - Remove duplicate display of VRF RD on IP address view
|
||||
* [#2895](https://github.com/digitalocean/netbox/issues/2895) - Fix filtering of nullable character fields
|
||||
|
||||
v2.5.6 (2019-02-13)
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
import django_filters
|
||||
from django.conf import settings
|
||||
from django.db.models import Q
|
||||
from taggit.models import Tag
|
||||
|
||||
@ -14,12 +15,11 @@ class NullableCharFieldFilter(django_filters.CharFilter):
|
||||
"""
|
||||
Allow matching on null field values by passing a special string used to signify NULL.
|
||||
"""
|
||||
null_value = 'NULL'
|
||||
|
||||
def filter(self, qs, value):
|
||||
if value != self.null_value:
|
||||
if value != settings.FILTERS_NULL_CHOICE_VALUE:
|
||||
return super().filter(qs, value)
|
||||
qs = self.get_method(qs)(**{'{}__isnull'.format(self.name): True})
|
||||
qs = self.get_method(qs)(**{'{}__isnull'.format(self.field_name): True})
|
||||
return qs.distinct() if self.distinct else qs
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user