From 1da13d787f844912fcd77cf83941e3f3ffee1f17 Mon Sep 17 00:00:00 2001 From: Challenger Date: Fri, 9 Jun 2023 18:38:01 +0530 Subject: [PATCH] Changed the format to get input --- CDC_Backend/scripts/add_students.py | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/CDC_Backend/scripts/add_students.py b/CDC_Backend/scripts/add_students.py index e540204..35503f6 100644 --- a/CDC_Backend/scripts/add_students.py +++ b/CDC_Backend/scripts/add_students.py @@ -17,17 +17,24 @@ def run(*args): if args[0] in ("manual", "man") : if not args: raise ValueError("Invalid number of arguments passed") - + + print("id\troll_no\tname\tbranch\tphone_number\tcpi\tdegree\tbatch") for i in range(1, int(args[1])+1): + details = input() + details = details.split(",") + details = [i.strip() for i in details] + details = [int(details[0]), int(details[1]), details[2], details[3], + int(details[4]), float(details[5]), details[6], details[7]] + student = Student.objects.create( - id = input("Enter id: "), - roll_no = input("Enter roll_no: "), - name = input("Enter name: "), - branch = input("Enter branch: "), - phone_number = input("Enter phone_number: "), - cpi = input("Enter cpi: "), - degree = input("Enter degree: "), - batch = input("Enter batch: ") + id = details[0], + roll_no = details[1], + name = details[2], + branch = details[3], + phone_number = details[4], + cpi = details[5], + degree = details[6], + batch = details[7], ) student.save()