• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python models.Student类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: zapisz_result

def zapisz_result(request):
    if request.method == 'POST':
        imie1 = request.POST.get("imie")
        nazwisko1 = request.POST.get("nazwisko")
        przedmiot = request.POST.get("przedmiot")
        if imie1 == '' or nazwisko1 == '':
            subjects = Wyklad.objects.all()
            return render(request, 'zapisy/zapisz.html', {'subjects':subjects, 'error':True})
        try:
            student_1 = Student.objects.get(imie=imie1, nazwisko=nazwisko1)
            text = '%s %s zostal znaleziony w bazie. ' % (student_1.imie, student_1.nazwisko)
        except:
            student_1 = Student(imie=imie1, nazwisko=nazwisko1)
            student_1.save()
            text = '%s %s nie zostal znaleziony. Dodano studenta do bazy. ' % (student_1.imie, student_1.nazwisko)
        przedmiot_1 = Wyklad.objects.get(nazwa=przedmiot)
        try:
            student_2 = przedmiot_1.studenci.get(imie=imie1, nazwisko=nazwisko1)
            print 'student ', student_2.imie, ' jest juz zapisany na ', przedmiot_1.nazwa
            return render_to_response('zapisy/zapisz.html', {'odpowiedz':True, 'odpowiedz2':text+'Student jest juz zapisany za zajecia'})
        except:
            przedmiot_1.studenci.add(student_1)
            return render_to_response('zapisy/zapisz.html', {'odpowiedz':True, 'odpowiedz2':text+'Student zostal zapisany na zajecia'})
    else:
        return render_to_response('zapisy/zapisz.html', {'error':True})
开发者ID:adriangawin,项目名称:django_project,代码行数:25,代码来源:views.py


示例2: create_instance_test

def create_instance_test():
    t1 = Teacher.create(name='t1')
    t2 = Teacher.create(name='t2')
    s1 = Student.create(name = 's1', teacher=t1)
    s2 = Student.create(name = 's2', teacher=t1)
    s3 = Student.create(name = 's3', teacher=t2)
    s4 = Student.create(name = 's4', teacher=t2)
开发者ID:EmuxEvans,项目名称:py_learn,代码行数:7,代码来源:test.py


示例3: test_create_student

 def test_create_student(self):
     with test_database(TEST_DB, (Student,)):
         self.create_students(),
         self.assertEqual(Student.select().count(), 2)
         self.assertNotEqual(
             Student.select().get().password, 'password'
         )
开发者ID:ZyzzyxTech,项目名称:leaderboard-python,代码行数:7,代码来源:app_tests.py


示例4: upload

def upload(request):
    '''
    Upload a csv and store the students' imformation in the database.
    '''
    if request.method == "POST":  # form submitted
        try:
            csv = request.FILES['csv']
            if csv.size > 4096:
                return render(request, 'error.html', {'str':'文件尺寸过大'})
            else:
                for line in csv:
                    line = line.strip('\r\n\xef\xbb\xbf')  # delete the useless characters
                    words = line.split(',')
                    if len(words) == 0:
                        continue
                        
                    paras = dict()
                    paras['num'] = int(words[0])
                    paras['tot'] = 0  # total score
                    for i in xrange(1,6):
                        paras[subjects[i]] = int(words[i+1])  # scores of the subjects
                        paras['tot'] += paras[subjects[i]]
                    paras['name']=words[1]
                    
                    stu = Student(**paras)
                    try:
                        stu.clean_fields()  # check the scores of the students 
                    except:
                        return render(request, 'error.html', {'str':'学生信息错误'})
                    stu.save()
                return render(request, 'notify.html', {"str":"导入csv文件成功"})  # upload succeeded
        except:
            return render(request, 'error.html', {'str':'您没有上传文件或文件格式错误,具体文件格式详见帮助'})
    else:
        return render(request, 'upload.html')
开发者ID:mayukuner,项目名称:HITCS,代码行数:35,代码来源:views.py


示例5: insert_item

def insert_item(argv):
    '''Takes the system arguments as parameter and then inserts the item.

    Keyword arguments:
    argv -- An array of command line arguments passed to the program.
    '''
    if argv[2] == "school":
        school = School.create(name=argv[3])
        print "New school: " + str(School.get(School.name == argv[3]))
    elif argv[2] == "batch":
        batch = Batch.create(school=argv[3], name=argv[4])
        print "New batch: " + str(Batch.get(Batch.name == argv[4]))
    elif argv[2] == "student":
        print "New student:",
        if len(argv) > 6:
            student = Student.create(batch=argv[3],
                                     age=argv[4],
                                     last_name=argv[5],
                                     first_name=argv[6])
            print str(Student.get(Student.age == argv[4] and
                                  Student.last_name == argv[5] and
                                  Student.first_name == argv[6]))
        else:
            student = Student.create(batch=argv[3],
                                     age=argv[4],
                                     last_name=argv[5])
            print str(Student.get(Student.age == argv[4] and
                                  Student.last_name == argv[5]))
    elif argv[2] == "exercise":
        exercise = Exercise.create(student=argv[3],
                                   subject=argv[4],
                                   note=argv[5])
        print "New Exercise: " + str(exercise)
开发者ID:bennettbuchanan,项目名称:holbertonschool-higher_level_programming,代码行数:33,代码来源:main.py


示例6: modify1

def modify1(request):
    '''
    Receive the form containing a student's information
    and update the student's infromation in the database.
    '''
    try:
        cmd = request.POST.get('cmd')
        paras = dict()
        paras['num'] = int(request.POST.get('num'))
        if cmd == 'edit':  # edit the student's infromation
            paras['name'] = request.POST.get('name')
            paras['tot'] = 0
            
            for subject in subjects[1:]:
                paras[subject] = int(request.POST.get(subject))
                paras['tot'] += paras[subject]
                
            stu=Student(**paras)
            stu.clean_fields()  # validate the fields of the students, if not, an error will be raised
            stu.save()

            return render(request, 'query.html', {"table":[[Student.objects.get(num=paras['num']), Student.objects.filter(tot__gt=paras['tot']).count()+1]]})
        else:  # delete the student from the database
            Student.objects.filter(num=paras['num']).delete()
            return render(request, 'notify.html', {"str":"学生信息成功删除"})
    except:
        return render(request, 'error.html', {"str":"学生信息错误,请正确填写"});
开发者ID:mayukuner,项目名称:HITCS,代码行数:27,代码来源:views.py


示例7: add_student

def add_student(request):
    from uuid import uuid4

    if request.method == 'POST':
        name = escape(request.POST.get('name', None).strip())
        username = escape(request.POST.get('username', None).strip())
        password = escape(request.POST.get('password', None).strip())
        rno = escape(request.POST.get('rno', None).strip())
        dob = escape(request.POST.get('dob', None).strip())
        course = escape(request.POST.get('course', None).strip())
        year = escape(request.POST.get('year', None).strip())
        semester = escape(request.POST.get('semester', None).strip())
        image1 = request.FILES.get('image1')
        image2 = request.FILES.get('image2')
        image3 = request.FILES.get('image3')
        image4 = request.FILES.get('image4')
        image1.name = '{}{}'.format(uuid4().hex, image1.name[image1.name.rfind('.'):])
        image2.name = '{}{}'.format(uuid4().hex, image2.name[image2.name.rfind('.'):])
        image3.name = '{}{}'.format(uuid4().hex, image3.name[image3.name.rfind('.'):])
        image4.name = '{}{}'.format(uuid4().hex, image4.name[image4.name.rfind('.'):])
        student = Student(name=name, username=username, password=password, rollno=rno, dob=dob,
                          course=course, year=year, semester=semester, image1=image1, image2=image2,
                          image3=image3, image4=image4)
        student.save()

        return HttpResponseRedirect('/dashboard')

    return HttpResponseRedirect('/forms')
开发者ID:zishanAhmad,项目名称:attendance-1,代码行数:28,代码来源:views.py


示例8: save

 def save(self, role=1):
     user = Account(**self.data)
     user.role=role
     user.save()
     stuusr=Student(stuid=user.username,grade="20"+user.username[0:2])
     stuusr.save()
     return user
开发者ID:ihciah,项目名称:xk-database,代码行数:7,代码来源:account.py


示例9: add_student

def add_student(request):
	if request.method == "POST":
		id_number = request.POST.get('id_number', '')
		first_name = request.POST.get('first_name', '')
		last_name = request.POST.get('last_name','')
		student = Student(id_number=id_number, first_name=first_name, last_name=last_name)
		student.save()
	return HttpResponseRedirect('/')
开发者ID:roselleebarle04,项目名称:class-list,代码行数:8,代码来源:views.py


示例10: get

 def get(self):
     stubStudents = [ "rush8192", "kshin" ]
     for student in stubStudents:
         matchingStudent = Student.query(Student.student_id == student).get()
         if matchingStudent == None:
             studentObj = Student(student_id=student,academic_plans=[])
             studentObj.put()
             print "populated db with student: " + student
开发者ID:rush8192,项目名称:course-planner,代码行数:8,代码来源:main.py


示例11: setUpClass

 def setUpClass(cls):
     global o1_id
     
     o1 = Student()
     o1.url_number = 1
     o1.public_profile.realname = '李小兵'
     o1.save()
     
     o1_id = o1.id
开发者ID:NCZkevin,项目名称:pyweb-test,代码行数:9,代码来源:tests.py


示例12: post

 def post(self):
     user = users.get_current_user()
     if not user:
         self.redirect(users.create_login_url(self.request.uri))
         return
     next_active_assignemnt = None
     if (self.request.get('type') == 'Student'):
         rose_username = self.request.get('rose_username')
         new_student = Student(parent=get_parent_key(user),
                               id=rose_username,
                               first_name=self.request.get('first_name'),
                               last_name=self.request.get('last_name'),
                               rose_username=rose_username,
                               team=self.request.get('team'))
         new_student.put()
     elif (self.request.get('type') == 'Assignment'):
         active_assignment = Assignment(parent=get_parent_key(user),
                                        name=self.request.get('assignment_name'))
         if len(self.request.get('assignment_entity_key')) > 0:
             assignment_key = ndb.Key(urlsafe=self.request.get('assignment_entity_key'))
             if assignment_key:
                 assignment = assignment_key.get()
                 if assignment:
                     active_assignment = assignment
                     active_assignment.name = self.request.get('assignment_name')
         active_assignment.put()
         next_active_assignemnt = active_assignment.key.urlsafe()
     elif (self.request.get('type') == 'SingleGradeEntry'):
         assignment_key = ndb.Key(urlsafe=self.request.get('assignment_key'))
         student_key = ndb.Key(urlsafe=self.request.get('student_key'))
         student = student_key.get()
         score = int(self.request.get('score'))
         new_grade_entry = GradeEntry(parent=assignment_key,
                                      id=student.rose_username,
                                      assignment_key=assignment_key,
                                      student_key=student_key,
                                      score=score)
         new_grade_entry.put()
         next_active_assignemnt = assignment_key.urlsafe()
     elif (self.request.get('type') == 'TeamGradeEntry'):
         assignment_key = ndb.Key(urlsafe=self.request.get('assignment_key'))
         score = int(self.request.get('score'))
         team = self.request.get('team')
         student_query = Student.query(Student.team==team, ancestor=get_parent_key(user))
         for student in student_query:
             new_grade_entry = GradeEntry(parent=assignment_key,
                                          id=student.rose_username,
                                          assignment_key=assignment_key,
                                          student_key=student.key,
                                          score=score)
             new_grade_entry.put()
         next_active_assignemnt = assignment_key.urlsafe()
     if next_active_assignemnt:
       self.redirect("/?active_assignemnt=" + next_active_assignemnt)
     else:
       self.redirect("/")
开发者ID:RoseMobileEndpoints,项目名称:GradeRecorderBackend,代码行数:56,代码来源:main.py


示例13: testStudent

    def testStudent(self):
        who = Student()

        who.setStudentID(1)
        who.setStudentName("Decebal")
        who.setStudentGroup("Dacia")

        assert who.getStudentID() == 1
        assert who.getStudentName() == "Decebal"
        assert who.getStudentGroup() == "Dacia"
开发者ID:harababurel,项目名称:homework,代码行数:10,代码来源:Test.py


示例14: save

 def save(self,commit=True):
     user = User.objects.create_user(self.cleaned_data['studentid'], '', '000000')
     user.is_staff = True
     user.save()
     theclass = Class.objects.get(id = self.cleaned_data['studentclass'])
     student = Student(user=user,realname=self.cleaned_data['username'],\
         theclass=theclass,sex=self.cleaned_data['studentsex'])
     if commit:
         student.save()
     return student
开发者ID:andyzsf,项目名称:ERP_Django,代码行数:10,代码来源:forms.py


示例15: register

def register(request):
    if request.POST:
        post = request.POST
        new_student = Student(
        Username = post["username"],
        Password= post["password"],
        Institute = post["institute"],
        Contact_way  = post["contact_way"],
        Email = post["email"]) 
        new_student.save()
    return render_to_response("gegister.html")
开发者ID:clllyw,项目名称:Project,代码行数:11,代码来源:views.py


示例16: save

 def save(self, commit=True):
     user = User.objects.create_user(self.cleaned_data["studentid"], "", "000000")
     user.is_staff = True
     user.save()
     theclass = Class.objects.get(id=self.cleaned_data["studentclass"])
     student = Student(
         user=user, realname=self.cleaned_data["studentname"], theclass=theclass, sex=self.cleaned_data["studentsex"]
     )
     if commit:
         student.save()
     return student
开发者ID:HowieWang,项目名称:ComPerformance,代码行数:11,代码来源:forms.py


示例17: save

    def save(self):
        user = Account(**self.data)
        user.save()
        if self.role.data == 1:
            stuusr = Student(stuid=self.username.data)
            stuusr.save()
        if self.role.data == 3:
            teausr = Teacher(teaid=self.username.data)
            teausr.save()

        return self.username.data, self.role.data
开发者ID:jt-wang,项目名称:xk-database,代码行数:11,代码来源:admin.py


示例18: saveDataFromRequest

 def saveDataFromRequest(self, req_body):
     request_objs = req_body.splitlines()
     students = json.loads(request_objs[0])
     activities = json.loads(request_objs[1])
     comments = json.loads(request_objs[2])
     
     Student.get_from_json(students)
     
     Comment.get_from_json(comments) 
     
     Activity.get_from_json(activities) 
开发者ID:vkcis350,项目名称:NetterProject,代码行数:11,代码来源:main.py


示例19: generateStudent

def generateStudent():
    student = Student()
    student.name = random.choice(NAMES)
    student.gender = random.choice(GENDERS)
    student.age = random.choice(AGES)
    student.university = random.choice(UNIVERSITIES)
    student.department = random.choice(DEPARTMENTS)
    student.percent_sem1 = randomPercent()
    student.percent_sem2 = randomPercent()
    student.percent_sem3 = randomPercent()
    student.percent_sem4 = randomPercent()
    return student
开发者ID:akshaydewan,项目名称:tech-challenge,代码行数:12,代码来源:datagenerator.py


示例20: testStudent

    def testStudent(self):
        """
            Method tests the Student class.
        """
        who = Student(666)

        who.setStudentID(1)
        who.setStudentName("Decebal")
        who.setStudentGroup("Dacia")

        assert who.getStudentID() == 1
        assert who.getStudentName() == "Decebal"
        assert who.getStudentGroup() == "Dacia"
开发者ID:harababurel,项目名称:homework,代码行数:13,代码来源:Test.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.Submission类代码示例发布时间:2022-05-27
下一篇:
Python models.Stock类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap