else: print(student.name + " has no change") if no_insert_flag == 1: # skips to next. continue try: print('Creating user {0}.'.format(username)) user = User.objects.create_user(username=username) user.set_password(password) user.is_student=True user.save() assert authenticate(username=username, password=password) print('User {0} successfully created.'.format(username)) # create student - onetoneField with user student = Student(user=user) student.student_no = student_no student.name = name student.major = Major.objects.get(title=major) student.section = Section.objects.get(section_no=section, course__year=year, course__title=title) student.group = Group.objects.get(section__section_no=section, section__course__year=year, section__course__title=title, group_no=group) student.save() except: print('There was a problem creating the user: {0}. Error: {1}.' \ .format(username, sys.exc_info()[1]))