From e81d005f5840e37e5e03ddee7085fcb2fef3882f Mon Sep 17 00:00:00 2001 From: d0c Date: Fri, 20 Jan 2023 17:42:48 +0100 Subject: [PATCH] fetch arch field --- suitablephones/management/commands/fetchphones.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/suitablephones/management/commands/fetchphones.py b/suitablephones/management/commands/fetchphones.py index b25d629..53c0936 100644 --- a/suitablephones/management/commands/fetchphones.py +++ b/suitablephones/management/commands/fetchphones.py @@ -25,10 +25,15 @@ class Command(BaseCommand): data = yaml.safe_load(stream) dev = Device() for key, value in data.items(): + if key == "architecture": + if type(value) == dict(): + setattr(dev, key, value) + else: #type(value) == str(): + setattr(dev, key, dict({ 'cpu' : value })) #match caso: # case dict(): # print('dict') - if key == "bluetooth": + elif key == "bluetooth": # get() returned more than one Bluetooth -- it returned 2! bt = Bluetooth.objects.filter(**value) # __exact? https://docs.djangoproject.com/en/4.1/ref/models/querysets/#exact