create_derivational_groups.py
710 Bytes
#-*- coding:utf-8 -*-
from django.core.management.base import BaseCommand
from dictionary.models import Entry, DerivationalGroup, connect_entries
from time import sleep
class Command(BaseCommand):
def handle(self, **options):
create_derivational_groups()
def create_derivational_groups():
for entry in Entry.objects.all():
print entry.name
for rel_entry in entry.rel_entries.all():
try:
connect_entries(entry, rel_entry)
except DerivationalGroup.DoesNotExist:
entry = Entry.objects.get(pk=entry.pk)
rel_entry = Entry.objects.get(pk=rel_entry.pk)
connect_entries(entry, rel_entry)