Register Your Neo4j-Based Models to Django Admin

A Paradise Papers Example

Cristina
Neo4j Developer Blog
4 min readJul 9, 2021

--

If you’re a Django developer, you may have already found the popular py2neo toolkit and may have some experience using Neomodel and/or the Neo4j python driver directly. But how well do these tools play with Django?

Thankfully for Django developers, the Neo4j ecosystem provides a quick way to spin up an example app — the Paradise Papers Search App — based on the Paradise Papers dataset, conveniently available on Neo4j Sandbox.

This post will be a quick walkthrough of how to register a model on the Paradise Papers Search app. For more details, check out our previous post on the topic here:

Local Setup — Sandbox Database

First step, set up your local environment:

clone the repo:

git clone git@github.com:neo4j-examples/paradise-papers-django.git

In a virtual environment, install the requirements:

pip install -r requirements.txt

Next you’ll need to point your app to a sandbox instance of the database.

In Neo4j Sandbox, create an account and select Paradise Papers by ICIJ.

Back in the Sandbox UI, tap “Connection details” to find the database’s Bolt URL, username, and password.

In your local environment, set the DATABASE_URL variable using the credentials found in the Sandbox admin:

export DATABASE_URL=bolt://<Username>:<Password>@<IP Address>:7687

In paradise_papers_search/fetch_api/admin, add the models you would like to explore using the admin:

Add the admin URL to urls.py (if you haven’t done so already):

Because Django’s admin authentication still goes through Django models, you will you need to set up a (relational) user database in your settings file and run the migrations.

Example settings snippet:

Running the migrations:

After that, create the admin superuser:

Run the app!

Start searching at http://127.0.0.1:8000/

Log in to the admin at http://127.0.0.1:8000/admin

--

--