Skip to content
Snippets Groups Projects
Commit 6a7296af authored by Christophe Henry's avatar Christophe Henry
Browse files

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

bugfix: Do not erase @context during serialisation when already defined (startinblox/djangoldp-packages/djangoldp#153)
parent 3f5a2e14
No related branches found
No related tags found
1 merge request!107bugfix: Do not erase @context during serialisation when already defined...
Pipeline #1145 passed
......@@ -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]
else:
data["@context"] = settings.LDP_RDF_CONTEXT
return super(JSONLDRenderer, self).render(data, accepted_media_type, renderer_context)
......
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