source: telemeta/management/commands/telemeta-init-formats.py @ 20ef7d80

cremcrem2devdev2diademsdj1.6feature/breadcrumbsfeature/ts-0.5feature/ts-0.5.4feature/writecachegenericinstru_searchlamlam2mapsv3mergenlivemultirelease/1.4.4sabiodsecurityserversocialstoragetelecastertest
Last change on this file since 20ef7d80 was c8cdfbe, checked in by yomguy <yomguy@…>, 3 years ago

add migrations, fix format

  • Property mode set to 100644
File size: 787 bytes
Line 
1from optparse import make_option
2from django.conf import settings
3from django.core.management.base import BaseCommand, CommandError
4from django.contrib.auth.models import User
5from django.template.defaultfilters import slugify
6from telemeta.models import *
7from telemeta.util.unaccent import unaccent
8import logging
9import codecs
10
11class Command(BaseCommand):
12    help = "Init original formats from a txt file (see files in example/init/"
13    args = "path"
14    admin_email = 'webmaster@parisson.com'
15
16    def handle(self, *args, **options):
17        path = args[0]
18        file = open(path, 'r')
19        for format in file.readlines():
20            if not OriginalFormat.objects.filter(value=format):
21                format = OriginalFormat(value=format)
22                format.save()
23
24
25
26
27
Note: See TracBrowser for help on using the repository browser.