Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Using force_text for indexing message #746

Merged
merged 2 commits into from

3 participants

Bernhard Vallant Jannis Leidel Justin Caratzas
Bernhard Vallant

verbose_name_plural can be a functional proxy object as it is possible to use ugettext_lazy for it, if you wouldn't use force_text, the output would be:

All documents removed.
Indexing 203 <django.utils.functional.__proxy__ object at 0x30aed10>.
Indexing 19 <django.utils.functional.__proxy__ object at 0x30a1a50>.
Indexing 999 <django.utils.functional.__proxy__ object at 0x332f650>.
Bernhard Vallant lazerscience using force_text for indexing message.
verbose_name_plural may be a functional proxy object from ugettext_lazy,
it should be forced to be a string!
7d55f25
Jannis Leidel
Owner

force_text is the Django>1.4.5 version of force_unicode. Since the latter will be supported for a while and is the only available in older versions I suggest to use it instead.

Justin Caratzas bigjust merged commit 0e8bd20 into from
Adam Wentz floppya referenced this pull request from a commit in floppya/django-haystack
Bernhard Vallant lazerscience replacing `force_text` with `force_unicode`. #746 4caaefd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 27, 2013
  1. Bernhard Vallant

    using force_text for indexing message.

    lazerscience authored
    verbose_name_plural may be a functional proxy object from ugettext_lazy,
    it should be forced to be a string!
Commits on Mar 4, 2013
  1. Bernhard Vallant
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 2 deletions.
  1. +2 −2 haystack/management/commands/update_index.py
4 haystack/management/commands/update_index.py
View
@@ -8,7 +8,7 @@
from django.core.exceptions import ImproperlyConfigured
from django.core.management.base import LabelCommand
from django.db import reset_queries
-from django.utils.encoding import smart_str
+from django.utils.encoding import smart_str, force_unicode
from haystack import connections as haystack_connections
from haystack.query import SearchQuerySet
@@ -241,7 +241,7 @@ def update_backend(self, label, using):
total = qs.count()
if self.verbosity >= 1:
- print "Indexing %d %s." % (total, smart_str(model._meta.verbose_name_plural))
+ print "Indexing %d %s." % (total, force_unicode(model._meta.verbose_name_plural))
pks_seen = set([smart_str(pk) for pk in qs.values_list('pk', flat=True)])
batch_size = self.batchsize or backend.batch_size
Something went wrong with that request. Please try again.