# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-03-24 15:39
from __future__ import unicode_literals

from django.db import migrations
from django.utils import timezone
from datetime import datetime

start_date = timezone.make_aware(datetime(2016, 5, 2) , timezone.get_current_timezone())
end_date = timezone.make_aware(datetime(2017, 5, 22), timezone.get_current_timezone())
election_nomination_start_datetime = timezone.make_aware(datetime(2017, 3, 28), timezone.get_current_timezone())
election_nomination_end_datetime = timezone.make_aware(datetime(2017, 4, 17, 23, 59, 59), timezone.get_current_timezone())
election_vote_start_datetime = timezone.make_aware(datetime(2017, 5, 1), timezone.get_current_timezone())
election_vote_end_datetime = timezone.make_aware(datetime(2017, 5, 3, 23, 59, 59), timezone.get_current_timezone())

def add_year(apps, schema_editor):
    SACYear = apps.get_model('voting', 'SACYear')
    SACYear.objects.create(start_date=start_date, end_date=end_date,
                           election_nomination_start_datetime=election_nomination_start_datetime,
                           election_nomination_end_datetime=election_nomination_end_datetime,
                           election_vote_start_datetime=election_vote_start_datetime,
                           election_vote_end_datetime=election_vote_end_datetime)

def remove_year(apps, schema_editor):
    SACYear = apps.get_model('voting', 'SACYear')
    SACYear.objects.get(start_date=start_date, end_date=end_date).delete()


class Migration(migrations.Migration):

    dependencies = [
        ('voting', '0001_initial'),
    ]

    operations = [
       migrations.RunPython(
            add_year,
            reverse_code=remove_year),

    ]

Add year migration