Using the Neo4j graph database with Python and Django.

Hello! I’m a beginner in the world of development and I have a project in mind to learn more and help the community where I live. However, my web application requires a graph database, and I’m having trouble integrating Django with Neo4j. There is limited material on this topic on YouTube, and I’m quite confused. Could someone provide me with an explanation or point me to materials that can clarify how to use these together?
I appreciate it in advance!

You need to first decide what degree of integration you’re looking for. If you want to use Django models and the ORM, you need to consider something like Django Neomodel. Otherwise, you can just connect to the database directly using their Python interface.

Note: In both cases you’re still going to need to use a database for Django itself.

I’ve decided to use Django Neomodel! I did some research on it and visited the link you recommended, but to be honest… I didn’t quite grasp it. What do you suggest I study before I start trying to understand this library/package?

Make sure you’re comfortable with Django first - then just dive in and start playing with it. I don’t think anything beats experimenting with a new package as far as learning and understanding are concerned.

Sure, I’m binge-watching playlists about using Django on YouTube and learning a lot. Right after, I’ll try to wrap my head around Django Neomodel.

Thank you very much for your help, have a great week!

Hi Ken! I’m also facing the same issue. I’m quite comfortable with django and I have learned graph databases recently. It’s good that Django offers class models for neo4j but seems like I cannot authenticate users without the help of SQL. I have searched forums and most of the people could not apply authentication with neo4j graph database. Do you think I better use SQL for authentication and store the rest of the data on neo4j? For example, I could copy the ID of a user from SQL and create a person label in neo4j with the ID I copy from SQL and store everything in neo4j. Looking forward to your opinion. If it’s possible to authenticate users with neomodel then that would be amazing.

1 Like

While it is possible to create a backend for Django to allow Django itself to work with a non-relational database (e.g., Djongo), it’s still my recommendation that you have a relational database for Django itself, and any non-relational database be used as extra sources of data and not the default.