testappproj/testapp/management/commands/seed_db.py
author amit@thunder
Mon, 12 Jul 2010 15:16:52 +0530
changeset 6 d0f107095b1a
parent 0 0b061d58aea3
permissions -rw-r--r--
changes to image comparison methods

import sys
from datetime import datetime
from random import randrange 

from django.core.management.base import NoArgsCommand
from django.contrib.auth.models import User






from testapp.models import Test_User


def seed_db():
    """ a method to seed the database with random data """
    
#    defaultMentor = userEvents.createSuUser("admin", "admin@example.com", "123456", datetime.now(), "M")
#    mentor_profile = defaultMentor.get_profile()
#    userEvents.updateProfile(mentor_profile, {'rights':"AD"})
    
    for i in range(1,21):
        
        username = 'user'+str(i)
        email = username+'@example.com'
        password = '123456'
        fullname='user user'
#        dob = datetime.now()
#        gender = "M"
#        user = userEvents.createUser(username,email,password,dob,gender)
#        create_notification("NU", user)
        user=User.objects.create_user(username=username,email=email,password=password)
        user.is_active = True
        user.save()
        test_user=Test_User(user_id=user.id,fullname=fullname)
        test_user.save()


class Command(NoArgsCommand):
    
    def handle_noargs(self, **options):
        """ Just copied the code from seed_db.py """
        
        seed_db()