# -*- coding: utf-8 -*-
# Generated by Django 1.11.15 on 2020-02-17 10:07
from __future__ import unicode_literals

import datetime

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


def set_start(apps, schema_editor):
    Event = apps.get_model('events', 'Event')

    for event in Event.objects.all():
        if event.start_time and event.start_date:
            event.start = get_current_timezone().localize(
                datetime.datetime.combine(
                    event.start_date,
                    event.start_time
                )
            )
            event.save()


class Migration(migrations.Migration):

    dependencies = [
        ('events', '0013_event_start'),
    ]

    operations = [
        migrations.RunPython(set_start)
    ]

# -*- coding: utf-8 -*-
# Generated by Django 1.11.15 on 2020-02-17 10:07
from __future__ import unicode_literals

import datetime

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


def set_start(apps, schema_editor):
    Event = apps.get_model('events', 'Event')

    for event in Event.objects.all():
        if event.start_date:
            if event.start_time:
                event.start = get_current_timezone().localize(
                    datetime.datetime.combine(
                        event.start_date,
                        event.start_time
                    )
                )
            else:
                event.start = event.start_date

            event.save()


class Migration(migrations.Migration):

    dependencies = [
        ('events', '0013_event_start'),
    ]

    operations = [
        migrations.RunPython(set_start)
    ]

Fix event migration