def add_keys(apps, schema_editor):
    """
    We can't import the Post model directly as it may be a newer
    version than this migration expects. We use the historical version.
    """
    Page = apps.get_model('pages', 'Page')
    ContentType = apps.get_model('contenttypes', 'ContentType')
    key = ''
    try:
        key = 'home'
        Page.objects.get(english_title=key)
    except Exception:
        Page.objects.create(title='صفحه اصلی', english_title=key,
            is_show_in_home=True)
    try:
        key = 'library'
        Page.objects.get(english_title=key)
    except Exception:
        Page.objects.create(title='کتابخانه', english_title=key,
            is_show_in_home=False)
    try:
        key = 'category'
        Page.objects.get(english_title=key)
    except Exception:
        Page.objects.create(title='دسته بندی', english_title=key,
            is_show_in_home=False)
    try:
        key = 'contact_us'
        Page.objects.get(english_title=key)
    except Exception:
        Page.objects.create(title='تماس با ما', english_title=key,
            is_show_in_home=False)
    try:
        key = 'about_us'
        Page.objects.get(english_title=key)
    except Exception:
        Page.objects.create(title='درباره ما', english_title=key,
            is_show_in_home=False)
    try:
        key = 'my_products'
        Page.objects.get(english_title=key)
    except Exception:
        Page.objects.create(title='محصولات من', english_title=key,
            is_show_in_home=False)
    try:
        key = 'download_manager'
        Page.objects.get(english_title=key)
    except Exception:
        Page.objects.create(title='دانلود منیجر', english_title=key,
            is_show_in_home=False)
    try:
        key = 'file_manager'
        Page.objects.get(english_title=key)
    except Exception:
        Page.objects.create(title='مدیریت فایل', english_title=key,
            is_show_in_home=False)
    try:
        key = 'user_invitation'
        Page.objects.get(english_title=key)
    except Exception:
        Page.objects.create(title='دعوت از دوستان', english_title=key,
            is_show_in_home=False)
    new_ct = ContentType.objects.get_for_model(Page)
    Page.objects.filter(polymorphic_ctype__isnull=True).update(
        polymorphic_ctype=new_ct)
