本文整理匯總了Python中students.models.Student.klasses方法的典型用法代碼示例。如果您正苦於以下問題:Python Student.klasses方法的具體用法?Python Student.klasses怎麽用?Python Student.klasses使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類students.models.Student
的用法示例。
在下文中一共展示了Student.klasses方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: init
# 需要導入模塊: from students.models import Student [as 別名]
# 或者: from students.models.Student import klasses [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.'