view band/management/commands/untextile.py @ 162:27b38cc65ca4

Set defaults for BooleanFields. THis suppresses a warning in Django 1.7 since the default changed in Django 1.6.
author Brian Neal <bgneal@gmail.com>
date Thu, 02 Apr 2015 19:03:46 -0500
parents 7b52e8ef01ec
children
line wrap: on
line source
"""
untextile.py - A command to remove the use of Textile by updating the models.

"""
import textile

from django.core.management.base import NoArgsCommand
from photologue.models import Gallery


class Command(NoArgsCommand):
    help = 'Updates models by un-textiling text fields'

    def handle_noargs(self, **options):

        for gallery in Gallery.objects.all():
            gallery.description = textile.textile(gallery.description,
                                                  encoding='utf-8',
                                                  output='utf-8')
            gallery.save()