Skip to content
Snippets Groups Projects
Commit 44b9046d authored by Jean-Baptiste's avatar Jean-Baptiste
Browse files

bugfix: correctly manage head of the graph

parent 3a705899
No related branches found
No related tags found
1 merge request!45Resolve "'NoneType' object has no attribute '_meta'"
Pipeline #838 passed
...@@ -59,7 +59,7 @@ class LDListMixin: ...@@ -59,7 +59,7 @@ class LDListMixin:
try: try:
list = next( list = next(
filter(lambda o: list[self.parent.url_field_name] == o[self.parent.url_field_name], object_list)) filter(lambda o: list[self.parent.url_field_name] == o[self.parent.url_field_name], object_list))
except (KeyError, TypeError): except (KeyError, TypeError, StopIteration):
pass pass
try: try:
...@@ -350,8 +350,13 @@ class LDPSerializer(HyperlinkedModelSerializer): ...@@ -350,8 +350,13 @@ class LDPSerializer(HyperlinkedModelSerializer):
def get_value(self, dictionary): def get_value(self, dictionary):
try: try:
object_list = dictionary["@graph"] object_list = dictionary["@graph"]
container_id = Model.container_id(self.parent.instance) if self.parent.instance is None:
obj = next(filter(lambda o: container_id in o[self.url_field_name], object_list)) obj = next(filter(
lambda o: not hasattr(o, self.parent.url_field_name) or "./" in o[self.url_field_name],
object_list))
else:
container_id = Model.container_id(self.parent.instance)
obj = next(filter(lambda o: container_id in o[self.url_field_name], object_list))
item = super().get_value(obj) item = super().get_value(obj)
full_item = None full_item = None
if item is empty: if item is empty:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment