diff --git a/core/views/caves.py b/core/views/caves.py index e2d7837..8df801b 100644 --- a/core/views/caves.py +++ b/core/views/caves.py @@ -262,27 +262,29 @@ def cavepage(request, karea, subpath): kpath = karea + subpath # print(f" ! cavepage:'{kpath}' kataster area:'{karea}' rest of path:'{subpath}'") - cave = Cave.objects.get(url = kpath) # ideally this will be unique - print(f" ! cavepage: url={kpath} -- {cave}") try: - r = rendercave(request, cave, cave.slug()) - return r - + cave = Cave.objects.get(url = kpath) # ideally this will be unique except Cave.DoesNotExist: # probably a link to text or an image e.g. 1623/161/l/rl89a.htm i.e. an expoweb page # cannot assume that this is a simple cave page, for a cave we don't know. + # print(f" ! cavepage: url={kpath} A cave of this name does not exist") return expo.expopage(request, kpath) except Cave.MultipleObjectsReturned: caves = Cave.objects.filter(url = kpath) + # print(f" ! cavepage: url={kpath} multiple caves exist") # we should have a -several variant for the cave pages, not just the svxcaves: return render(request, 'svxcaveseveral.html', {'settings': settings, "caves":caves }) + + try: + r = rendercave(request, cave, cave.slug()) + return r except NoReverseMatch: raise except: message = f'Failed to render cave: {kpath} (it does exist and is unique) because of a Django URL resolution error. Check urls.py.' return render(request,'errors/generic.html', {'message': message}) - return rendercave(request, cave, cave.slug(), cave_id=cave_id) + # return rendercave(request, cave, cave.slug(), cave_id=cave_id) def caveEntrance(request, slug): try: