NeoDjango

Integrating your Django project with the all features of Neo4j.

Why Neo4j?

Contents:

The PRIMARY AUTHORS are:

Getting Started

Installation

Configuration

Once you’ve installed neodjango and configure your Django project for connect to Neo4j.

Database Setup

An example settings.py:

INSTALLED_APPS = (
    # other apps
    "neodjango",
)

NEO4J_DATABASES = {
        'default' : {
                'HOST':'localhost',
                'PORT':7474,
                'ENDPOINT':'/db/data'
        }
}

Nodes

Model

  • Writing nodes.py

    from neodjango.db import models

    class Label(models.Model):
    class Meta:

    display = “name”

Querying

  • Retrieving all objects

    >>> Label.objects.all()
    [<Node#id: property>, <Node#id: property>, <Node#id: property>, <Node#id: property>]
    
  • Retrieving specific objects with filters

    >>> Label.objects.filter(name='Guido')
    [<Node#id: property>,]
    
  • Retrieving a single object with get

    >>> Label.objects.get(name='Lawrence')
    <Node#id: property>
    
    >>> Label.objects.get(id=42)
    <Node#id: property>
    
  • Retrieving all relationships of objects

    >>> Label.objects.get(name='Ken Thompson').relationships()
    
    >>> Label.objects.get(name='Emil Eifrem').Created()
    

Indices and tables