new_contents: # -*- coding: utf-8 -*-
  # Generated by Django 1.9.11 on 2016-12-07 18:54
  from __future__ import unicode_literals
  
  from django.db import migrations
  from markdown import Markdown
  
  
  def update_field(model, field):
      md = Markdown(extensions=[
          'markdown.extensions.extra',
          'markdown.extensions.nl2br',
      ], output_format="html5")
  
      for f in model.objects.all():
          val = getattr(f, field)
          if val:
              try:
                  setattr(f, field, md.convert(val))
                  f.save()
              except:
                  # not valid markdown - leave it as-is
                  pass
  
  
  def md_to_html(apps, schema_editor):
      ProductTranslation = apps.get_model("shuup", "ProductTranslation")
      CategoryTranslation = apps.get_model("shuup", "CategoryTranslation")
      PaymentMethodTranslation = apps.get_model("shuup", "PaymentMethodTranslation")
      ShippingMethodTranslation = apps.get_model("shuup", "ShippingMethodTranslation")
      update_field(ProductTranslation, "description")
      update_field(CategoryTranslation, "description")
      update_field(PaymentMethodTranslation, "description")
      update_field(ShippingMethodTranslation, "description")
  
  
  class Migration(migrations.Migration):
  
      dependencies = [
          ('shuup', '0019_order_total_limit_behavior_component'),
      ]
  
      operations = [
          migrations.RunPython(md_to_html, migrations.RunPython.noop)
      ]
  
subject: add migration to convert markdown to html