Library / SDK
graphql-python/graphene-django avatar
graphql-python/graphene-django

Graphene-Django: a GraphQL schema generated from your model layer

Build powerful, efficient, and flexible GraphQL APIs with seamless Django integration.

4,394 stars766 forksPythonMIT

At a glance

What is it?
Graphene-Django wraps Graphene so a Django app can serve one GraphQL endpoint built from its own models, ORM querysets and test client. It suits teams replacing a REST layer with a typed query API, and it costs you tight control over SQL.
Who is it for?
Adopt Graphene-Django if your API surface is wide, mostly reads, and already sits on Django's ORM. Do not adopt it if you need hand written SQL, a documented pagination contract, or a release cadence tighter than the gap between v3.2.2 and v3.2.3.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 151 days ago.
What is it written in?
Mainly Python, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on November 22, 2026, and from our analysis. They are not legal advice.

From daily snapshots

Star history

  • graphql-python/graphene-django4,394 ★ · +2
Star history
Repository2026-09-232026-11-22
graphql-python/graphene-django4.4k4.4k

2 Stars in the last 60 days, measured from the daily GitHub snapshot. Compare with other projects

Editorial analysis

The gap Graphene-Django fills between ORM views and a typed query API

A Django project built with plain views ends up with one serializer per resource and a URL route per combination of filters. Adding a field means editing a serializer, editing a view, and often editing a third view for the write path. Graphene-Django takes a different route: you declare types once, and the client asks for the fields it wants in one request. The audience is a backend team that already has models, migrations and a permission system, and now wants a single endpoint instead of a growing set of routes. The cost of that endpoint is that the schema becomes a public contract that clients will depend on, which is a different kind of commitment from adding a view. The library is MIT licensed, and the repository is not archived, with the last push on 2026-06-24.

DjangoObjectType derives fields from the model, so the model decides the schema

The core mechanism is one class. Subclass DjangoObjectType, point its Meta at a model, and the GraphQL type takes its field set from that model. Nothing in the usage example names a single Graphene field; MyModelType has a body of exactly one line, model = MyModel. That is the whole contract, and it is also the whole constraint. Field types come from the Django model declaration, so the column type on your table decides what the client can query, and changing that column changes the API. The query root is a normal Graphene ObjectType with a resolver that returns MyModel.objects.all(), meaning the queryset, not a plain list, crosses into the GraphQL layer. Resolution happens per field, so any default or annotation on that queryset runs where it is declared.

One settings key, one app entry, and a schema path that must resolve

Registration takes two lines in settings.py. The app goes into INSTALLED_APPS as graphene_django, and the GRAPHENE dict points at a dotted path, myapp.schema.schema, that Python will import when the schema is built. Nothing else is required. There is no settings key in the example for authentication, for a database routing policy, or for a depth limit, so anything beyond the default view needs a look at the documentation rather than the README. The upside of the string path is that the schema module can import models through the normal app registry, so it follows Django's own startup order.

Install, then a first query through GraphiQL

Installation is a single pip command.

bash
pip install graphene-django

After the app is registered, the endpoint is one path entry with the GraphiQL explorer enabled, which is what you want while the schema is still moving.

python
from django.urls import path
from graphene_django.views import GraphQLView
from . import schema

urlpatterns = [
    # ...
    path('graphql/', GraphQLView.as_view(graphiql=True)), # Given that schema path is defined in GRAPHENE['SCHEMA'] in your settings.py
]

Run the server and open /graphql/ in a browser. The explorer loads the schema you declared in myapp.schema.schema, and a request for mymodels { id name } should return one object per row in MyModel, with no errors.

The README promises pagination and filter integration, then never wires either up

The feature list advertises Django pagination support and compatibility with Django's form and validation system, but no section of the README configures either. The usage example stops at graphene.List(MyModelType), which has no argument at all, so a client cannot pass a page number or a filter to the query shown. setup.py lists django-filter>=22.1 and djangorestframework>=3.6.3 in tests_require. That gap matters at review time. A team reading the feature list will assume pagination is on by default, and ship an endpoint that returns every row of a large table in one response, because the default resolver has no pagination argument.

Each resolved field becomes an ORM hit unless you intervene

This is the failure mode that decides adoption for a large schema. Because types are generated from models, every field of a related model resolved in the same query triggers its own database access unless the queryset was annotated or select_related ahead of time. There is no optimizer setting in the README's configuration block. The README also does not document a query depth limit or a complexity limit, which means a client can nest a recursive self relation until the database, not the schema, stops it. If your models contain self referential or many to many relations, that is the first thing to measure.

Graphene-SQLAlchemy and Strawberry generate types the same way but bind elsewhere

The repository points at Graphene-SQLAlchemy as the sibling project, and the difference is not style but binding. Both take a database model and generate GraphQL types from it. Graphene-SQLAlchemy attaches to a SQLAlchemy session and declarative models, so the same schema pattern applies to a project that left Django for SQLAlchemy, or one that never used Django. Strawberry takes the opposite route: it asks you to annotate fields with a type, keeping full control of what appears in the schema and pushing the mapping work back onto you. For a team that wants a GraphQL endpoint whose shape matches an existing Django model, Graphene-Django writes less code. For a team that wants the schema to be an independent artefact that a backend migration does not silently rewrite, that generated coupling is the cost.

Editorial conclusion

Adopt Graphene-Django if your API surface is wide, mostly reads, and already sits on Django's ORM. Do not adopt it if you need hand written SQL, a documented pagination contract, or a release cadence tighter than the gap between v3.2.2 and v3.2.3. Before writing a resolver, send one nested query and read the number of queries it produces.

Frequently asked questions

What is Graphene-Django?

It is a library that connects Django to Graphene so a Django app can serve a GraphQL API. It generates GraphQL types from Django models and exposes the endpoint through Django's URL configuration.

How do you install Graphene-Django?

The README gives one command: pip install graphene-django. After that you add graphene_django to INSTALLED_APPS and set GRAPHENE['SCHEMA'] to the dotted path of your schema module.

How does Graphene-Django generate types from Django models?

You subclass DjangoObjectType and set Meta.model to your Django model, and the GraphQL type takes its fields from that model. The README example adds no other field declarations.

Can you test a Graphene-Django API with Django's test client?

Yes. graphene_django.utils.testing provides GraphQLTestCase, which takes the schema through GRAPHENE_SCHEMA and exposes a query method that returns a response with data and errors.

Which Django versions does Graphene-Django declare support for?

The setup.py classifiers list Django 3.2, 4.1, 4.2, 5.1 and 5.2, along with Python 3.8 through 3.12 and PyPy.

Official sources

  1. graphql-python/graphene-django on GitHub
  2. License: MIT
  3. Project website
  4. README
  5. Releases
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/graphql-python-graphene-django.svg)](https://hysenlabs.com/projects/graphql-python-graphene-django)

Star history chart for your README

markdown
[![Star history](https://hysenlabs.com/chart/graphql-python-graphene-django.svg)](https://hysenlabs.com/projects/graphql-python-graphene-django)

Was this useful?