Skip to content

Commit

Permalink
Use is_queryset_empty from django-fluent-utils instead (already in deps)
Browse files Browse the repository at this point in the history
  • Loading branch information
vdboor committed Jun 17, 2015
1 parent 180ad9a commit b798dce
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions fluent_contents/rendering.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from django.utils.safestring import mark_safe
from django.utils.translation import get_language
from parler.utils.context import smart_override
from fluent_utils.django_compat import is_queryset_empty
from fluent_contents import appsettings
from fluent_contents.cache import get_rendering_cache_key, get_placeholder_cache_key_for_parent
from fluent_contents.extensions import PluginNotFound, ContentPlugin
Expand All @@ -25,17 +26,6 @@
except ImportError:
TemplateAdapter = None

if django.VERSION >= (1,6):
def _is_queryset_empty(queryset):
"""
Check whether a queryset is empty by using ``.none()``.
"""
return queryset.query.is_empty()
else:
from django.db.models.query import EmptyQuerySet
def _is_queryset_empty(queryset):
return isinstance(queryset, EmptyQuerySet)

# This code is separate from the templatetags,
# so it can be called outside the templates as well.

Expand Down Expand Up @@ -125,7 +115,7 @@ def render_placeholder(request, placeholder, parent_object=None, template_name=N
if output is None:
# No full-placeholder cache. Get the items
items = placeholder.get_content_items(parent_object, limit_parent_language=limit_parent_language).non_polymorphic()
if _LOG_DEBUG and _is_queryset_empty(items): # Detect qs.none() was applied
if _LOG_DEBUG and is_queryset_empty(items): # Detect qs.none() was applied
logging.debug("- skipping regular language, parent object has no translation for it.")

if fallback_language \
Expand Down

0 comments on commit b798dce

Please sign in to comment.