本文整理匯總了Python中people.models.Person.set_password方法的典型用法代碼示例。如果您正苦於以下問題:Python Person.set_password方法的具體用法?Python Person.set_password怎麽用?Python Person.set_password使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類people.models.Person
的用法示例。
在下文中一共展示了Person.set_password方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: handle
# 需要導入模塊: from people.models import Person [as 別名]
# 或者: from people.models.Person import set_password [as 別名]
def handle(self, *options, **kwoptions):
if len(options) != 1:
raise CommandError('Must provide a file')
with open(options[0]) as f:
for line in f:
line = line.strip()
# ingore blank lines
if line == '':
continue
(last_name, first_name, email, username) = line.split(' ')
password_chars = string.ascii_lowercase + string.digits
password = ''.join(random.choice(password_chars)
for x in range(6))
person = Person(first_name = first_name,
last_name = last_name,
username = username,
email = email)
person.set_password(password)
person.is_staff = True
person.is_superuser = True
mail_text = EMAIL_TEXT % (first_name, username, password)
send_mail('Welcome to ROSEdu People',
mail_text,
'[email protected]',
[email])
person.save()
print 'Invited %s %s' % (first_name, last_name)