Exemplo n.º 1
0
def handle():
    randomize.out("\ntags:")
    for i in range(50):
        Tag(name=randomize.string(20)).save()
        randomize.out('.')
    print "\nusers:",
    for i in range(5):
        user, created = User.objects.get_or_create(
            username='******' % i,
            email='*****@*****.**' % str(i),
            password='******',
            is_blog_author=True,
            first_name=u'Иван%s' % str(i),
            second_name=u'Иванович%s' % str(i),
            last_name=u'Иванов%s' % str(i),
        )

        if created:
            user.save()

        print "\nposts"
        for j in range(50):
            post = Post(
                author=user,
                title='Post%s' % str(i),
                text='Post text %s' % str(i),
                published=True,
                enable_comments=True,
            )
            post.save()
            if randomize.boolean():
                post.tags = Tag.objects.order_by('?')[:randomize.integer(1, 6)]
            randomize.out('.')
        randomize.out('.')
Exemplo n.º 2
0
def handle():

    print u"\nGenerate Log:",
    for i in range(100):
        try:
            Log(
                date = randomize.datetime(),
                type = randomize.integer(),
                subject = randomize.string(255),
                content = randomize.text(),
                ).save()
            randomize.out('.')
        except:
            randomize.out('*')
Exemplo n.º 3
0
def handle():

    print u"\nGenerate Log:",
    for i in range(100):
        try:
            Log(
                date=randomize.datetime(),
                type=randomize.integer(),
                subject=randomize.string(255),
                content=randomize.text(),
            ).save()
            randomize.out('.')
        except:
            randomize.out('*')
Exemplo n.º 4
0
def handle (  ):
    randomize.out("\ntags:")
    for i in range( 50 ):
        Tag(
            name = randomize.string(20)
            ).save()
        randomize.out('.')
    print "\nusers:",
    for i in range( 5 ):
        user, created = User.objects.get_or_create(
            username       = '******' %  i ,
            email          = '*****@*****.**' % str( i ),        
            password       = '******', 
            is_blog_author = True,   
            first_name     = u'Иван%s' % str( i ),
            second_name    = u'Иванович%s' % str( i ),
            last_name      = u'Иванов%s' % str ( i ),
        )
        
        if created:
            user.save ()
        
        print "\nposts"
        for j in range ( 50 ):
            post=Post (
                author          = user,
                title           = 'Post%s' % str ( i ),
                text            = 'Post text %s' % str ( i ),
                published       = True,
                enable_comments = True,
            )
            post.save ()
            if randomize.boolean():
                post.tags = Tag.objects.order_by('?')[:randomize.integer(1, 6)]
            randomize.out('.')
        randomize.out ( '.' )