def handle(self, *args, **options): # Get projects if args: projects = [Project.objects.get(number=n) for n in args] else: projects = Project.objects.all() models = Index.searchable_models() n = 0 for model in models: instances = model.objects.all() for instance in instances: if instance._project in projects: new = Index._index(instance) if new: n += 1 print "Indexed %d objects." % n
def initial_types(): return [ContentType.objects.get_for_model(m).id for m in Index.searchable_models()]