import mrkazi livesock excel tablr

This commit is contained in:
2026-02-09 14:45:45 +03:30
parent f13851a30d
commit c02c165ff9
4 changed files with 51 additions and 2 deletions

View File

@@ -1,8 +1,9 @@
import pandas as pd
from django.core.management.base import BaseCommand
from django.utils.dateparse import parse_datetime
from apps.livestock.models import LiveStock, LiveStockType, LiveStockSpecies
from apps.herd.models import Herd
from apps.livestock.models import LiveStock, LiveStockType, LiveStockSpecies
from apps.tag.models import Tag
@@ -16,6 +17,7 @@ class Command(BaseCommand):
path = options['excel_path']
df = pd.read_excel(path)
records = df.to_dict(orient='records')
print(records[1])
self.stdout.write(self.style.SUCCESS(f"{len(records)} records loaded."))
@@ -46,7 +48,7 @@ class Command(BaseCommand):
herd_cache[herd_code] = herd
tag_code = r.get('national_id_livestock_code')
tag = Tag.objects.filter(code=tag_code).first()
tag = Tag.objects.filter(tag_code=tag_code).first()
if not tag:
skipped += 1
continue