Skip to main content

Neo4j integration for Django, and much more tools for deployment of consequent websites...

Project description

(bulb is the child of the old 'neo4j_for_django' package.)

You can find the full documentation on ReadTheDocs here.

Presentation :

transparent logo bulb

The bulb package extends the Django framework to make it compatible with the Neo4j databases. But it also provides an advanced support for modern technologies (CDNs, SFTP servers, ...) and a lot of tools for better user experience and performances (a full administration crafted on graph databases' logic, staticfiles compression, ...).

Installation :

  1. First, open a terminal.

  1. Then, go into your Django project or start your virtual environment if you have one :

    Example :

> cd my_projects/my_django_project

  1. Finally, execute :
> pip install bulb

or if it doesn't work :

> python -m pip install bulb

  1. To check if all works open the terminal, and go in your virtual environment if you have one. Then, run the python shell of your Django project and try to import the bulb package :
(my_env) > python shell
Python 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 14:57:15) [MSC v.1915 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import bulb

If no error message is raised, that's good.

Getting started :


The bulb package is very fast to setup. Just 2 steps are needed to execute yours first cypher requests.

If you don't have already install the package, please see the installation page.

1. Set the bulb settings to your project

A very simple step, just import the set_bulb_settings_on() in the file of your Django project :


from bulb import set_bulb_settings_on

Then, use this method on all the datas contained in your file. The locals() function return a dictionary that contains all of these datas. So just put this at the bottom of your file :



Finally, and always in the same file (just below the method that we have previously set), configure yours Neo4j credentials with the 3 parameters :

BULB_DATABASE_URI is the bolt address of your database. Generally on a local server, the bolt address is 'bolt://localhost:7687'. But you can find more details in the parameters of your Neo4j database and on the official documentation.

BULB_DATABASE_ID is your Neo4j database id or username. By default the id is defined on 'neo4j'.

BULB_DATABASE_PASSWORD is your Neo4j database password. By default the password is defined on 'neo4j' too. But normally and if you don't have change the password before, during the first run of the Neo4j database, we will ask you to replace the default password by another.

Example :


BULB_DATABASE_URI = "bolt://localhost:7687"



You're project is now configured to work with bulb !

WARNING : don't forget to remove the default admin page at the creation of your project, cause the Django administration is'nt already supported by bulb. Else, a "LookupError: No installed app with label 'admin'." will be raised.

from django.contrib import admin
from django.urls import path, include

urlpatterns = [
    # path('admin/',,
    path('blog/', include("my_project.urls"))

2. Run a first cypher query

bulb can be used in all the files of your project. So in one of these files, import the gdbh object.


from bulb.db import gdbh

g-db-h means Graph Database Handler and it is an instance of the GraphDatabaseHandler() class. This instance will be used all the times where we will want to interact with the Neo4j database.

Now you can use the w_transaction() method of the gdbh object, to send a query to the database :

gdbh.w_transaction("CREATE (:Person) {first_name: 'Adrien', age: 18}")

The w_transaction() means writing transaction, so use it preferably when you want to create or modify datas in the database.
We also find the r_transaction() method, which one should be used preferably to retrieve datas from the database.

For now, if you have any doubt, use the w_transaction() method.

You can find the full documentation on ReadTheDocs here.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for bulb-core, version 0.0.41
Filename, size File type Python version Upload date Hashes
Filename, size bulb_core-0.0.41-py3-none-any.whl (255.1 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size bulb-core-0.0.41.tar.gz (209.3 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page