Commit 0659689e 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 #6494 passed with stage
in 1 minute and 29 seconds
......@@ -21,12 +21,21 @@ from djangoldp.models import LDPSource, Model
from djangoldp.permissions import LDPPermissions
get_user_model()._meta.rdf_context = {"get_full_name": "rdfs:label"}
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)
......
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