djangonic way to deal with rdf?
Asked Answered
C

2

9

I was looking for an RDF project for django and I cant find any active.

This seems to be a good one http://code.google.com/p/django-rdf, but the last commit was in 2008, (4 years ago). The group in google-groups seems to be abandoned. Last no-spam post was in 2008. Therefore it has no support for new django versions.

Is there any library or some prebuilt open source app to easily expose rdf data?

Maybe is easy to solve, like writing a view and returning something using https://github.com/RDFLib/rdflib in one or two lines of code, but I can't figure it out how to do it...

The idea using RDFlib would be to take a django object or collection of objects and transform it to rdf in some way, maybe using an rdf parser.

I thought I could give html responses if the client request "accept:text/html", and RDF if the user requested the same page using a html accept header with rdf+xml or rdf+turtle (and it could exist an app that handles that for me)

Confraternity answered 6/7, 2012 at 16:3 Comment(2)
What's the question here? Your proposed solution of writing a view that uses rdflib seems perfectly fine.Arlin
@Arlin I proposed a solution, but I have no implementation of it. As I said: "I can't figure it out". The answer would be: use this, do that and that, and you have rdf working ok for django models. Should I edit and reformulate my question?Confraternity
M
4

From what little I've read of RDF you are probably going to have to do manual work to get meaningful RDF statements from Django models since it's not a simple data representation format like JSON, it is trying to encode semantic meaning.

That said, have a look at django-rdflib:
https://github.com/odeoncg/django-rdflib

There doesn't seem to be any documentation (and it seems to have been built for a specific app) but the author has posted here about a manage.py syncvb command that generates an RDF graph from existing Django models:
https://groups.google.com/d/msg/django-rdf/14WVK7t88PE/ktAKJo-aCfUJ

Not sure exactly what views django-rdflib provides, but if it can make an RDFlib graph for you then you can probably use the serialization plugins provided by RDFlib to output rdf+xml or whatever from your own view.

Moss answered 24/7, 2012 at 10:33 Comment(2)
I thought I could give html responses if the client request "accept:text/html", and RDF if the user requested the same page using a html accept header with rdf+xml or rdf+turtle (and it could exist an app that handles that for me) I finally will go with this solution you post on "write yourself", but i'll do it using microdata, embedding semantics in html.Confraternity
you should also check out tastypieapi.org ...it's designed for auto-generating views from Django models (i.e. an 'API') and has a mechanism for connecting different serializers depending on content negotiation headers (ships with XML and JSON). may be possible to plug all these bits together into something that works for you...Moss
M
1

http://code.google.com/p/djubby/

SURF is useful as a RDF->object mapper (or RDFAlchemy)

injecting rdfa into your templates should work either (if you want to avoid triplestores)

you can also expose your database as a sparql endpoint using a tool such as http://d2rq.org/

Mangan answered 8/1, 2013 at 2:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.