def handle(self, *args, **options): logger.info("Clear catalog table.....") Catalog.objects.all().delete() logger.info("Start loading.....") import urllib2 doc = urllib2.urlopen(IMPORT_CATALOG_URL) dom = minidom.parse(doc) items=dom.getElementsByTagName('genre') for i in items: c = Catalog() c.original_id = i.getAttribute('id') c.name = i.getAttribute('title_ru') c.lft = i.getAttribute('lft') c.rght = i.getAttribute('rght') c.tree_id = i.getAttribute('tree_id') c.level = i.getAttribute('level') c.save() print i.getAttribute('id') logger.info("adding...%s" % c.name_slug) logger.info("Done")