本文整理汇总了Python中models.Course.desc方法的典型用法代码示例。如果您正苦于以下问题:Python Course.desc方法的具体用法?Python Course.desc怎么用?Python Course.desc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Course
的用法示例。
在下文中一共展示了Course.desc方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_course
# 需要导入模块: from models import Course [as 别名]
# 或者: from models.Course import desc [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})