poteznyKrolik
5/29/2011 - 9:54 AM

Neo4j graph model with Django

Neo4j graph model with Django

from neo4j.model import django_model as models

class Movie(models.NodeModel):
    title = models.Property(indexed=True)
    year = models.Property()
    href = property(lambda self: ('movie/%s/' % (self.node.id,)))

    def __unicode__(self):
        return self.title


class Actor(models.NodeModel):
    name = models.Property(index=True)
    href = property(lambda self: ('/actor/%s/' %
        (self.node.id,)))

    def __unicode__(self):
        return self.name