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.
36 lines
1.0 KiB
36 lines
1.0 KiB
# -*- coding: utf-8 -*-
|
|
from django.core.management.base import BaseCommand, CommandError
|
|
from django.conf import settings
|
|
import xlrd
|
|
from theme.models import Tag, Theme
|
|
from city.models import City
|
|
|
|
CITIES = settings.MEDIA_ROOT+'/import/cities_inflect.xls'
|
|
TAGS = settings.MEDIA_ROOT+'/import/tags_inflect.xls'
|
|
|
|
import inspect, os
|
|
|
|
class Command(BaseCommand):
|
|
def handle(self, *args, **options):
|
|
f = open(TAGS, 'r')
|
|
book = xlrd.open_workbook(file_contents=f.read())
|
|
sheet = book.sheet_by_index(0)
|
|
row_list = [sheet.row_values(row_number) for row_number in range(sheet.nrows)]
|
|
print(row_list[2][0])
|
|
for row_number, row in enumerate(row_list[2:]):
|
|
url = row[1]
|
|
print(url)
|
|
inflect = row[3]
|
|
if inflect:
|
|
Tag.objects.filter(url=url).update(inflect=inflect)
|
|
|
|
|
|
|
|
#City.objects.filter(url=url).update(inflect=row[4])
|
|
|
|
|
|
#try:
|
|
# city = City.objects.get(id=id)
|
|
#except City.DoesNotExist:
|
|
# print()
|
|
|
|
|