You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2.2 KiB

You are in the next unreleased version of Graphene-Django ( Please read to learn how to upgrade.

Graphene Logo Graphene-Django Build Status PyPI version Coverage Status

A Django integration for Graphene.


For instaling graphene, just run this command in your shell

pip install "graphene-django>"


Here is a simple Django model:

from django.db import models

class UserModel(models.Model):
    name = models.CharField(max_length=100)
    last_name = models.CharField(max_length=100)

To create a GraphQL schema for it you simply have to write the following:

from graphene_django import DjangoObjectType

class User(DjangoObjectType):
    class Meta:
        model = UserModel

class Query(graphene.ObjectType):
    users = graphene.List(User)

    def resolve_users(self):
        return UserModel.objects.all()

schema = graphene.Schema(query=QueryRoot)

Then you can simply query the schema:

query = '''
    query {
      users {
result = schema.execute(query)

To learn more check out the following examples:


After cloning this repo, ensure dependencies are installed by running:

python install

After developing, the full test suite can be evaluated by running:

python test # Use --pytest-args="-v -s" for verbose mode