def import_users Profile objects all delete for row in db iterate_tabl

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
def import_users():
Profile.objects.all().delete()
for row in db.iterate_table('users', 100):
user = Profile()
map = ('id=@, username=login, first_name=title, email=@'
',date_joined=createDate, website=homesite, contact=@'
',contact_type=@, date_joind=createDate, sex=@'
',notify_hits_now=@, notify_hits_2day=@, notify_hits_week=@'
',city_count=beenCitiesCounter, country_count=beenCountriesCounter'
',uid=@, thank_count=thanksCounter'
',question_count=questionsCounter, answer_count=answersCounter'
',question_notified=qnotified, comment_notify=@'
',question_notify=@, favourite_notify=favorites_notify'
)
converters = {
'first_name': not_null, 'website': not_null, 'contact': not_null,
'contact_type': contact_type_handler,
'sex': sex_handler,
'comment_notify': comment_notify_handler,
'favourite_notify': favourite_notify_handler,
'question_notify': question_notify_handler,
}
bulk_assign(user, row, map, converters)
user.save()
for key, XXX in parse_map_string(map):
print u'%s: %s' % (key, getattr(user, key))
p = Profile(username='****', is_superuser=True, is_staff=True)
p.set_password('****')
p.save()