def load_db(): print bcolors.WARNING+'Start loading data in DB' t = Tpa() t.name = 'tpa1com' t.domain ='tpa1.com' t.get_balance_url = 'http://%s/api/[user_id]/tpa1com/get_balance' % TPA_SERVER t.billing_page = 'http://%s/account/get-coins' % TPA_SERVER t.charge_url = 'http://%s/api/charge' % TPA_SERVER t.timeout_chating = 33 t.save() men = ['vova','fedor', 'oleg', 'serg', 'dima', 'alex'] women = ['olga','sveta', 'luba', 'marina', 'natasha', 'vera'] cmen = [] u = User() u.username = '******' u.set_password('admin') u.is_active=True u.is_staff=True u.is_superuser = True try: u.save() except: pass for m in men: print 'process..........%s' % m u = ChatUser() u.gender = 'm' u.name = m year = random.choice(range(1950, 2001)) month = random.choice(range(1, 13)) day = random.choice(range(1, 29)) u.birthday = str(year)+'-'+str(month)+'-'+str(day) u.email = m+'@gmail.com' cr = random.randint(0,5) country = (['Ukraine','Russia','Great Britain','Poland','Germany','USA']) city = (['Kiev','Odessa'], ['Moskow','Sant Peterburg'], ['London','Glasgo'], ['Washava','Krakiv'], ['Berlin','Munhen'], ['Texas','Chicago']) u.country = country[cr] u.city = city[cr][random.randint(0,1)] u.image = '/static/images/avatar.jpg' u.profile_url = m+'_plofile_url' u.culture = random.choice(['de','ru','en']) u.is_online = random.choice([True,False]) u.user_id = str(ChatUser.objects.all().count()) u.tpa = t u.save() cmen.append(u) for w in women: print 'process..........%s' % w u = ChatUser() u.gender = 'w' u.name = w year = random.choice(range(1950, 2001)) month = random.choice(range(1, 13)) day = random.choice(range(1, 29)) u.birthday = str(year)+'-'+str(month)+'-'+str(day) u.email = m+'@gmail.com' cr = random.randint(0,5) country = (['Ukraine','Russia','Great Britain','Poland','Germany','USA']) city = (['Kiev','Odessa'], ['Moskow','Sant Peterburg'], ['London','Glasgo'], ['Washava','Krakiv'], ['Berlin','Munhen'], ['Texas','Chicago']) u.country = country[cr] u.city = city[cr][random.randint(0,1)] u.image = '/static/images/avatar.jpg' u.profile_url = m+'_plofile_url' u.culture = random.choice(['de','ru','en']) u.is_online = random.choice([True,False]) u.user_id = str(ChatUser.objects.all().count()) u.tpa = t u.save() chat_c = ChatContacts() chat_c.owner = u rc = random.randint(0,5) chat_c.contact = cmen[rc] chat_c.tpa = t chat_c.save() chat_c = ChatContacts() chat_c.owner = cmen[rc] chat_c.contact = u chat_c.tpa = t chat_c.save() for u in range(5): men.append('man'+str(u)) women.append('woman'+str(u)) for m in men: u = User() u.username = m u.set_password('111') for m in women: u = User() u.username = m u.set_password('111') print 'Done loading data in DB'