harbor run -t openthoughts/tasktrove-exp-flat25-stackoverflow-v2-5k-stackoverflow-4488harbor download openthoughts/tasktrove-exp-flat25-stackoverflow-v2-5k-stackoverflow-4488Title: Implement a JSON:API compliant detail endpoint for NodeLicense in Django (no DRF)
Context We have a Django project that uses the OSF data model. I need to implement a JSON:API compliant detail endpoint for a single NodeLicense.
What to implement
Details and constraints
Acceptance criteria
What I would like to see (example approach)
Code scaffolding (reference, not required to copy exactly)
def node_license_detail(request, license_id): if request.method != "GET": return HttpResponseNotAllowed(["GET"]) try: lic = NodeLicense.objects.get(_id=license_id) except NodeLicense.DoesNotExist: error = { "errors": [ {"status": "404", "title": "Not Found", "detail": f"License '{license_id}' not found."} ] } return JsonResponse(error, status=404, content_type="application/vnd.api+json")
data = {
"data": {
"type": "licenses",
"id": lic._id,
"attributes": {
"name": lic.name,
"text": lic.text
}
}
}
return JsonResponse(data, content_type="application/vnd.api+json")
urlpatterns = [ path(f'{API_BASE}licenses/str:license_id/', node_license_detail), ]
Questions