Skip to content

Instantly share code, notes, and snippets.

@acdha
Last active August 29, 2015 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save acdha/8697917 to your computer and use it in GitHub Desktop.
Save acdha/8697917 to your computer and use it in GitHub Desktop.
django-haystack's update_index command extended to activate translations
# encoding: utf-8
"""Haystack's update_index command extended to activate translations
Source: https://gist.github.com/acdha/8697917
See https://github.com/toastdriven/django-haystack/pull/933
"""
from __future__ import absolute_import
from django.utils import translation
from haystack.management.commands.update_index import Command as DefaultCommand
class Command(DefaultCommand):
leave_locale_alone = True
def update_backend(self, label, using):
with translation.override(using):
super(Command, self).update_backend(label, using)
# encoding: utf-8
"""Haystack's update_index command extended to activate translations
Source: https://gist.github.com/acdha/8697917
See https://github.com/toastdriven/django-haystack/pull/933
"""
from __future__ import absolute_import
from django.conf import settings
from django.utils import translation
from haystack.management.commands.update_index import Command as DefaultCommand
class Command(DefaultCommand):
leave_locale_alone = True
def handle(self, *args, **kwargs):
with translation.override(settings.LANGUAGE_CODE):
super(Command, self).handle(*args, **kwargs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment