Create a gist now

Instantly share code, notes, and snippets.

@mhluongo /
Last active Dec 18, 2015

What would you like to do?
A quick example using neo4django with tastypie adapted from the tastypie tutorial (
from tastypie.resources import ModelResource
from .models import Entry
class EntryResource(ModelResource):
class Meta:
queryset = Entry.objects.all()
resource_name = 'entry'
from neo4django.auth.models import User
from neo4django.db import models
from django.template.defaultfilters import slugify
class Entry(models.NodeModel):
user = models.Relationship(User, related_name='entries',
rel_type='authored_by', single=True)
pub_date = models.DateTimeProperty(auto_now=True)
title = models.StringProperty(indexed=True)
slug = models.StringProperty()
body = models.StringProperty()
def __unicode__(self):
return self.title
def save(self, *args, **kwargs):
if not self.slug:
self.slug = slugify(self.title)[:50]
return super(Entry, self).save(*args, **kwargs)
from django.conf.urls import patterns, include
from myapp.api import EntryResource
entry_resource = EntryResource()
urlpatterns = patterns('',
# The normal jazz here...
#(r'^blog/', include('myapp.urls')),
(r'^api/', include(entry_resource.urls)),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment