From 9803ebe2e807aedc9d19dbd68b320ec27a7e37fd Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Fri, 8 Jul 2022 22:19:07 +0300 Subject: [PATCH] fix bug in Area creation --- parsers/caves.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/parsers/caves.py b/parsers/caves.py index 6b73c13..6c9d749 100644 --- a/parsers/caves.py +++ b/parsers/caves.py @@ -102,7 +102,7 @@ def do_pending_cave(k, url, area_1623): notes = default_note) if cave: cave.save() # must save to have id before foreign keys work. This is also a ManyToMany key. - cave.area.add(area_1623[0]) + cave.area.add(area_1623) cave.save() message = f" ! {k:12} {cave.underground_description}" DataIssue.objects.create(parser='caves', message=message, url=url) @@ -158,11 +158,10 @@ def readcaves(): DataIssue.objects.filter(parser='caves ok').delete() DataIssue.objects.filter(parser='entrances').delete() - area_1623 = Area.objects.update_or_create(short_name = "1623", parent = None) + area_1623, state = Area.objects.update_or_create(short_name = "1623", parent = None) # This seems to return a tuple, not a single object! i.e. (, True) #print(f' ! - READ CAVES: {area_1623}') - - area_1626 = Area.objects.update_or_create(short_name = "1626", parent = None) + area_1626, state = Area.objects.update_or_create(short_name = "1626", parent = None) print (" - Setting pending caves") # Do this first, so that these empty entries are overwritten as they get properly created.