Fix import

This commit is contained in:
Yohann D'ANELLO 2020-05-05 07:09:17 +02:00
parent 1e574208bd
commit 240b0472a0
1 changed files with 6 additions and 2 deletions

View File

@ -151,7 +151,7 @@ class Command(BaseCommand):
"country": args[10], "country": args[10],
"phone_number": args[11], "phone_number": args[11],
"school": args[12], "school": args[12],
"student_class": args[13].lower().replace('premiere', 'première'), "student_class": args[13].lower().replace('premiere', 'première') if args[13] else None,
"responsible_name": args[14], "responsible_name": args[14],
"responsible_phone": args[15], "responsible_phone": args[15],
"responsible_email": args[16], "responsible_email": args[16],
@ -245,7 +245,11 @@ class Command(BaseCommand):
"uploaded_at": args[4], "uploaded_at": args[4],
} }
with transaction.atomic(): with transaction.atomic():
try:
Solution.objects.create(**obj_dict) Solution.objects.create(**obj_dict)
except:
print("Solution exists")
continue
self.stdout.write(self.style.SUCCESS("Solutions imported")) self.stdout.write(self.style.SUCCESS("Solutions imported"))
with open("import_olddb/syntheses.csv") as f: with open("import_olddb/syntheses.csv") as f: