Fixed #231 -- Avoid fetching entire queryset from db

Patched ciritcal memory leak in ModelSelect2 widgets.
Boolean evaluation of queryset makes django fetch all
elements.

Thanks to @magicjohnson for discovering this issue
This commit is contained in:
Johannes Hoppe 2015-11-30 13:12:47 +01:00
parent 18647161a1
commit bb90be77b7
3 changed files with 5 additions and 2 deletions

View file

@ -1,6 +1,9 @@
Changelog Summary
=================
### v5.4.1
* Fixed memory leak in `ModelSelect2Mixin` and subclasses
### v5.4.0
* Added `Select2TagWidget` a light widget with tagging support

View file

@ -9,4 +9,4 @@ The app includes Select2 driven Django Widgets and Form Fields.
"""
__version__ = "5.4.0"
__version__ = "5.4.1"

View file

@ -351,7 +351,7 @@ class ModelSelect2Mixin(object):
:return: Filtered queryset
:rtype: :class:`.django.db.models.QuerySet`
"""
if not queryset:
if queryset is None:
queryset = self.get_queryset()
search_fields = self.get_search_fields()
select = Q()