get_entries_with_lemma_examples.py 544 Bytes
#-*- coding:utf-8 -*-

from django.core.management.base import BaseCommand

from dictionary.models import Lemma, get_ready_statuses


class Command(BaseCommand):
    args = 'none'

    def handle(self, **options):
        get_entries()


def get_entries():
    ready_statuses = get_ready_statuses()
    lemmas = Lemma.objects.filter(old=False,
                                  status__in=ready_statuses).order_by('entry_obj__name')
    for lemma in lemmas:
        if lemma.lemma_nkjp_examples.exists():
            print lemma.entry_obj.name