Commit 6a7296af authored by Christophe Henry's avatar Christophe Henry

bugfix: Do not erase @context during serialisation when already defined...

bugfix: Do not erase @context during serialisation when already defined (#153)
parent 3f5a2e14
Pipeline #6492 passed with stage
in 1 minute and 28 seconds
......@@ -25,8 +25,14 @@ class JSONLDRenderer(JSONRenderer):
media_type = 'application/ld+json'
def render(self, data, accepted_media_type=None, renderer_context=None):
if data is not None:
data["@context"] = settings.LDP_RDF_CONTEXT
if isinstance(data, dict):
context = data.get("@context")
if isinstance(context, list):
data["@context"] = [settings.LDP_RDF_CONTEXT] + context
elif isinstance(context, str) or isinstance(context, dict):
data["@context"] = [settings.LDP_RDF_CONTEXT, context]
data["@context"] = settings.LDP_RDF_CONTEXT
return super(JSONLDRenderer, self).render(data, accepted_media_type, renderer_context)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment