Notice: Over the next few months, we're reorganizing the App Engine documentation site to make it easier to find content and better align with the rest of Google Cloud products. The same content will be available, but the navigation will now match the rest of the Cloud products. If you have feedback or questions as you navigate the site, click Send Feedback.

Python 2 is no longer supported by the community. We recommend that you migrate Python 2 apps to Python 3.
Stay organized with collections Save and categorize content based on your preferences.

google.appengine.ext.ndb.django_middleware module


Django middleware for NDB.


class google.appengine.ext.ndb.django_middleware.NdbDjangoMiddlewaresource

Bases: object

Django middleware for NDB.

To use NDB with django, add


to the MIDDLEWARE_CLASSES entry in your Django file. Or, if you are using the ndb version from the SDK, use


It’s best to insert it in front of any other middleware classes, since some other middleware may make datastore calls and those won’t be handled properly if that middleware is invoked before this middleware.


process_exception(unused_request, unused_exception)source

Called by Django when a view raises an exception.


Called by Django before deciding which view to execute.

process_response(request, response)source

Called by Django just before returning a response.