Skip to content

Instantly share code, notes, and snippets.

@bugzPDX
Created February 17, 2015 19:51
Show Gist options
  • Save bugzPDX/a5c3472e9f2a6d00458a to your computer and use it in GitHub Desktop.
Save bugzPDX/a5c3472e9f2a6d00458a to your computer and use it in GitHub Desktop.
Creates Bulk Events
from django.utils import timezone
from django.core.management.base import BaseCommand
from airmozilla.main.models import Event
from airmozilla.starred.models import StarredEvent, Event
class Command(BaseCommand):
args = "Something"
help = "This is a help string"
def create_event(self):
# instantiate test event
#event = Event.objects.get(title='Test event')
event_count = int(input("Number of events to create: "))
title = ''
event_num = 1
# create more events
while event_count > 0:
# need it to start at +1 the num of events already created
event = Event(
# a unique title would be good
title='Title' + str(event_num),
# figure out how to generate a unique slug
slug='Slug' + str(event_num),
description='Event ' + str(event_num),
start_time=timezone.now(),
privacy=Event.PRIVACY_PUBLIC,
location=None,
)
event_count -= 1
event_num += 1
event.save()
def handle(self, *args, **options):
self.create_event()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment