本文整理匯總了Python中models.Course.instructor_email方法的典型用法代碼示例。如果您正苦於以下問題:Python Course.instructor_email方法的具體用法?Python Course.instructor_email怎麽用?Python Course.instructor_email使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類models.Course
的用法示例。
在下文中一共展示了Course.instructor_email方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: create_course
# 需要導入模塊: from models import Course [as 別名]
# 或者: from models.Course import instructor_email [as 別名]
def create_course(request):
""" Form to add a new course to our db
"""
def custom_validate(form_dict):
if form_dict['id_title'] == '': return False
response = {}
if request.method == 'POST':
form = KarmaForms.CreateCourseForm(request.POST)
if form.is_valid():
user_profile = request.user.get_profile()
new_course = Course()
new_course.instructor_email = form.cleaned_data['instructor_email']
new_course.instructor_name = form.cleaned_data['instructor_name']
new_course.title = form.cleaned_data['title']
new_course.desc = form.cleaned_data['desc']
new_course.school = user_profile.school
new_course.save()
user_profile.courses.add(new_course)
user_profile.save()
else:
#TODO: have ajax display error messages
print "Form is INVALID: %s" % form.errors
else:
# request method is NOT POST
form = KarmaForms.CreateCourseForm()
return render(request, 'n_lightbox_create_course.html', {'form': form})