from django.core.management.base import BaseCommand from content.models import Contact import re import subprocess class Command(BaseCommand): def handle(self, **kwargs): a = subprocess.check_output('rig', shell=True) m = re.match(r"(?P\w+) (?P\w+)[\n\r](?P
\w+(.*))[\n\r](?P\w(.*))[\n\r](?P[\(]\d+[\)]\s+\w+(.*))", a) firstname = m.group('first_name') lastname = m.group('last_name') address = m.group('address') city = m.group('city') phone = m.group('phone') contact = Contact(firstname=firstname) contact.lastname = lastname contact.address = address contact.city = city contact.phone = phone contact.save() print 'Content successfully added'