Skip to content

Instantly share code, notes, and snippets.

@benzkji
benzkji / search_indexes_untranslated.py
Created November 6, 2017 10:40
search_indexes_untranslated.py haystack aldryn_search
from aldryn_search.search_indexes import TitleIndex
from cms.models import CMSPlugin
from djangocms_misc.global_untranslated_placeholder.utils import get_untranslated_default_language
class UntranslatedTitleIndex(TitleIndex):
def get_plugin_queryset(self, language):
queryset = CMSPlugin.objects.filter(
language=get_untranslated_default_language()
@dcramer
dcramer / track_data.py
Created December 6, 2010 19:15
Tracking changes on properties in Django
from django.db.models.signals import post_init
def track_data(*fields):
"""
Tracks property changes on a model instance.
The changed list of properties is refreshed on model initialization
and save.
>>> @track_data('name')