|
|
|
@ -26,10 +26,10 @@ class Command(BaseCommand): |
|
|
|
repostajes_creados = 0 |
|
|
|
for repostaje_data in datos: |
|
|
|
try: |
|
|
|
vehiculo = Vehiculo.objects.get(id=repostaje_data["vehiculo"]) |
|
|
|
vehiculo = Vehiculo.objects.get(matricula=repostaje_data["vehiculo_matricula"]) |
|
|
|
|
|
|
|
creado = Repostaje.objects.create( |
|
|
|
vehiculo_id=vehiculo.id, |
|
|
|
vehiculo=vehiculo, |
|
|
|
fecha=repostaje_data['fecha'], |
|
|
|
kms=repostaje_data['kms'], |
|
|
|
litros=repostaje_data['litros'], |
|
|
|
@ -43,7 +43,7 @@ class Command(BaseCommand): |
|
|
|
repostajes_creados += 1 |
|
|
|
|
|
|
|
except Vehiculo.DoesNotExist: |
|
|
|
self.stderr.write(self.style.ERROR(f"Vehiculo '{repostaje_data['vehiculo']}' no encontrado.")) |
|
|
|
self.stderr.write(self.style.ERROR(f"Vehiculo con matrícula '{repostaje_data['vehiculo_matricula']}' no encontrado.")) |
|
|
|
|
|
|
|
self.stdout.write(self.style.SUCCESS(f'Se importaron {repostajes_creados} repostajes correctamente.')) |
|
|
|
|
|
|
|
|