Ejemplo n.º 1
0
Archivo: views.py Proyecto: WhiteRune/1
def create_student(request):
    """
    Creates student by student's name
    """
    student_name_from_request = request.GET.get('name')

    if not student_name_from_request:
        return HttpResponse('Student name missing')

    student = Student()
    student.name = student_name_from_request
    student.save()
    return HttpResponse('Student {} have been created'.format(student.name))
Ejemplo n.º 2
0
 def handle(self, *args, **options):
     faker = Faker()
     self.stdout.write('Start inserting Students')
     for _ in range(options['len']):
         self.stdout.write('Start inserting Students')
         student = Student()
         student.name = faker.first_name()
         student.surname = faker.last_name()
         student.sex = (faker.simple_profile()).get('sex')
         student.address = faker.street_address()
         student.description = faker.text()
         student.birthday = faker.date_of_birth()
         student.email = faker.company_email()
         student.save()
     self.stdout.write('End inserting Students')