本文整理汇总了Python中students.models.Student.set_password方法的典型用法代码示例。如果您正苦于以下问题:Python Student.set_password方法的具体用法?Python Student.set_password怎么用?Python Student.set_password使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类students.models.Student
的用法示例。
在下文中一共展示了Student.set_password方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: init
# 需要导入模块: from students.models import Student [as 别名]
# 或者: from students.models.Student import set_password [as 别名]
def init():
print 'Existing database will be wiped, continue? (y/n)'
choice = raw_input().strip()
if choice == 'y':
print 'Working...'
# Wipe db
clean()
# Common variable
pw = 'sesame'
# FYI
ACCOUNT_TYPES = {
1: 'teacher',
2: 'student',
3: 'parent',
}
# Create teachers
t = Teacher(first_name='Sesame', last_name='Teacher', email='[email protected]', user_type=1)
t.save()
t.set_password(pw)
t.save()
# Create classes
for i in range(3):
index = str(i+1)
name = 'Class #' + index
code = 'KLS' + index
start = end = datetime.now().date()
colour = "#" + index*6
k = Klass(teacher=t, name=name, code=code, start=start, end=end, colour=colour)
k.save()
# Create students
students = [
{
'first_name': 'Alton',
'last_name': 'Lau',
'email': '[email protected]'
}, {
'first_name': 'Marc',
'last_name': 'Lo',
'email': '[email protected]'
}, {
'first_name': 'Madigan',
'last_name': 'Kim',
'email': '[email protected]'
}
]
classes = Klass.objects.all()
for i in range(3):
s = students[i]
s = Student(first_name=s['first_name'], last_name=s['last_name'], email=s['email'], user_type=2)
s.save()
s.set_password(pw)
s.save()
s.klasses = classes[:i+1]
k = Klass.objects.all()[0]
s = Student.objects.all()
# Create notes
for i in range(3):
index = str(i+1)
detail = 'This is note #' + index
n = Note(klass=k, detail=detail)
n.save()
n.students = s[:i+1]
print 'All done, goodbye!'
else:
print 'Fine, I see how it is.'