当前位置: 首页>>代码示例>>Python>>正文


Python Course.teacher方法代码示例

本文整理汇总了Python中models.Course.teacher方法的典型用法代码示例。如果您正苦于以下问题:Python Course.teacher方法的具体用法?Python Course.teacher怎么用?Python Course.teacher使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Course的用法示例。


在下文中一共展示了Course.teacher方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: add_class

# 需要导入模块: from models import Course [as 别名]
# 或者: from models.Course import teacher [as 别名]
def add_class(request):
    name = request.POST['name']
    teacher = request.POST['teacher name']
    availability = request.POST['availability']
    description = request.POST['description']
    max_cap = request.POST['max_cap']
    c = Course()
    c.name = name
    c.teacher = teacher
    c.available = availability
    c.max_cap = max_cap
    c.description = description
    c.save()
    return HttpResponseRedirect(reverse('teacher'))
开发者ID:jkaashoek,项目名称:Iceblock,代码行数:16,代码来源:views.py

示例2: course_admin_update

# 需要导入模块: from models import Course [as 别名]
# 或者: from models.Course import teacher [as 别名]
def course_admin_update(request, course_id, prefix):
    if request.is_ajax():
        form = CourseForm(request.POST) if prefix == 'None' else CourseForm(request.POST, prefix=prefix) 
        if form.is_valid():
            try:
                course = Course.objects.get(pk=course_id)
                course.teacher = form.cleaned_data['teacher']
                course.name = form.cleaned_data['name'] 
                course.save()
                return HttpResponse('OK')
                
            except ObjectDoesNotExist:
                # create new object
                position = None
                if Course.objects.count() > 0:
                    course = Course.objects.order_by('-position').all()[0]
                    position = course.position

                else:
                    position = 1

                newcourse = Course()
                newcourse.teacher = form.cleaned_data['teacher']
                newcourse.name = form.cleaned_data['name']
                newcourse.position = position
                newcourse.save()
                response = {'created_object_id': newcourse.pk}
                return HttpResponse(json.dumps(response), mimetype="application/json") 
        else:
            errors_dict = {}
            if form.errors:
                for error in form.errors:
                    e = form.errors[error]
                    field = prefix+"-"+error;
                    errors_dict[field] = unicode(e)
            print errors_dict
            return HttpResponseBadRequest(json.dumps(errors_dict))
    else:
        return HttpResponseNotFound('You do not have permission to access this page!')
开发者ID:Darkmer,项目名称:masterchief,代码行数:41,代码来源:views.py


注:本文中的models.Course.teacher方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。