import mrkazi livesock excel tablr
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user