Support for django models?

Any support for django models as Neo4j has neomodel for django.
It will help dev to use dgraph seamlessly

2 Likes

There is no direct support for django models on Dgraph/DQL. I do understand that you would like a code-first approach.
You could try to get going with the Dgraph graphql API using a code-first approach using libraries like Graphene, and you could use a method like this to get the schema. You could then apply this schema to Dgraph and use the graphql API. See Step 2 in this link.

I also see a graphene-django library here, but I haven’t tried it.

Can I use the dgraph db direct with my django project ? some sample apps will really help.

I need some help here to be more specific, it doesnt work.

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.dgraph',
        'HOST': 'localhost:port',
    }
}

Hi Darshan, I don’t believe Django persistence has a Dgraph option yet.

Is there any other option to connect with dgraph db from django ?

Apart from the python client library for Dgraph and the graphql (graphene+Django) option (mentioned above), I am not aware of any other option.

So If i understood, I can use graphene models and its schema as a django models and use that schema directly to dgraph client library. This will work right?

Wondering whether fields supported by graphene will work with dgraph schema?

Graphql is an industry standard, and is quite mature. There may be some incompatibilities that you might discover, but it will definitely help cover many requirements (and reduce unnecessary data modeling effort). Please give it a try.

Like to bump that topic.
AFAICS there are two options for getting django to use digraph as a backend:

  1. Indirectly: Persisting data in e.g Postgres and utlizing somehow the sql-import api of dgraph by running a job etc.
  2. Directly: Integrating the official python client (pydgraph), by writing a plugin for dgraph like it exists for neo4j (neo4django)

Any other suggestions, ideas, poc?

Background: there’s a need to edit data in an interface by the end user