# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import migrations, models

TAGS = (
    # ( tag name, tag slug ),
    ("augmented reality", "augmented-reality"),
    ("big data", "big-data"),
    ("django", "django"),
    ("education", "education"),
    ("ipython", "ipython"),
    ("javascript", "javascript"),
    ("jupyter", "jupyter"),
    ("mobile", "mobile"),
    ("node.js", "node-js"),
    ("php", "php"),
    ("python", "python"),
    ("ruby on rails", "ruby-on-rails"),
    ("ruby", "ruby"),
    ("video games", "video-games"),
    ("web", "web"),
    ("zend", "zend"),
)


def add_tag_data(apps, schema_editor):
    Tag = apps.get_model('organizer', 'Tag')
    tag_list = []
    for tag_name, tag_slug in TAGS:
        tag_list.append(
            Tag(name=tag_name, slug=tag_slug))
    Tag.objects.bulk_create(tag_list)


def remove_tag_data(apps, schema_editor):
    Tag = apps.get_model('organizer', 'Tag')
    for _, tag_slug in TAGS:
        Tag.objects.filter(slug=tag_slug).delete()


class Migration(migrations.Migration):

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

    operations = [
        migrations.RunPython(
            add_tag_data,
            remove_tag_data)
    ]

@@ -58,16 +58,71 @@
 terals%0A%0A
+from functools import reduce%0Afrom operator import or_%0A%0A
 from dja
@@ -153,16 +153,47 @@
 , models
+%0Afrom django.db.models import Q
 %0A%0ATAGS =
@@ -1028,24 +1028,44 @@
 er', 'Tag')%0A
+    query_list = %5B%5D%0A
     for _, t
@@ -1081,24 +1081,113 @@
 n TAGS:%0A    
+    query_list.append(%0A            Q(slug=tag_slug))%0A    query = reduce(or_, query_list)%0A
     Tag.obje
@@ -1197,29 +1197,21 @@
 .filter(
-slug=tag_slug
+query
 ).delete

Optimize Tag data removal in migration.