Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

djangonic way to deal with rdf?

Tags:

django

rdf

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)

like image 517
jperelli Avatar asked Jul 06 '12 16:07

jperelli


2 Answers

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.

like image 131
Anentropic Avatar answered Nov 07 '22 12:11

Anentropic


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/

like image 38
Sweet Burlap Avatar answered Nov 07 '22 11:11

Sweet Burlap