def handle(self, *args, **options):
    name    = options['name']
    address = options['address']

    if not name or not address:
      self.stdout.write('Both name and address are required to add a house.')
      return

    # First let's try to find the owner
    owners = Owner.objects.filter(name=name)
    if owners:
      # There are owners, let's just grab the first one.
      owner = owners[0]
    else:
      owner = Owner(name=name)
      owner.save()
      self.stdout.write("Added %s" % owner)

    # Now that we have an owner, let's add the house:
    house = House(address=address, owner=owner)
    house.save()

    self.stdout.write("Added %s" % house)
  def handle(self, *args, **options):
    name = options['name']
    new_owner = Owner(name=name)
    new_owner.save()

    self.stdout.write("Added %s" % new_owner)