Commit 88993319 authored by Rafal's avatar Rafal

Add init_api command

parent babaa230
from app.API.models import API
from app.Tag.models import Tag
__author__ = 'Rafal'
from django.core.management.base import BaseCommand
class Command(BaseCommand):
help = 'Closes the specified poll for voting'
def add_arguments(self, parser):
parser.add_argument('poll_id', nargs='+', type=int)
def handle(self, *args, **options):
apis = [
['Hotele w Krakowie', 'Krakow'],
['Wypadki w Krakowie', 'Krakow'],
['Cmenatarze w Krakowie', 'Krakow'],
]
print "Creating APIs"
for api in apis:
print "Create {0}".format(api[0])
tag = Tag.objects.filter(name=api[1])[0]
new_api = API.objects.create(name=api[0])
new_api.tag = [tag, ]
new_api.save()
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment