You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
885 B
25 lines
885 B
import pydash as _;
|
|
from django.core.management import BaseCommand
|
|
|
|
_.map = _.map_;
|
|
_.filter = _.filter_
|
|
|
|
from common.models import Location
|
|
|
|
|
|
class Command(BaseCommand):
|
|
def handle(self, *args, **options):
|
|
print('---------------------------------------')
|
|
print('Generating locations...')
|
|
print('---------------------------------------')
|
|
|
|
_root = Location.objects.create(name='_root', type='_root')
|
|
|
|
depths = ('A', 'B', 'C', 'D')
|
|
|
|
for d1 in depths:
|
|
x = Location.objects.create(name='Страна %s' % d1, type='country', parent=_root)
|
|
for d2 in depths:
|
|
y = Location.objects.create(name='Регион %s-%s' % (d1, d2), type='region', parent=x)
|
|
for d3 in depths:
|
|
z = Location.objects.create(name='Город %s-%s-%s' % (d1, d2, d3), type='town', parent=y)
|
|
|