remove_whitespaces.py
495 Bytes
# -*- coding:utf-8 -*-
from django.core.management.base import BaseCommand
from webapp.models import Expression
class Command(BaseCommand):
help = 'Remove single expression meanings from database.'
def handle(self, *args, **options):
remove_whitespaces()
def remove_whitespaces():
for expr in Expression.objects.order_by('text'):
if expr.text != expr.text.strip():
print expr.text
expr.text = expr.text.strip()
expr.save()