Ajax Requests panel - proof of concept #253

wants to merge 2 commits into

5 participants


It's certainly not commit ready yet, but I wanted to open this pull request to facilitate feedback on this idea.

The code implements an "Ajax Requests" panel that lists out ajax requests that have occurred. You can then click on one of the requests to replace your current debug toolbar with the toolbar rendered for that ajax request.

Would you consider integrating a panel like this? If so, what sorts of changes would need to be made first? I'll happily write some tests. I'm also not very happy with storing the rendered toolbars in the session, so I'll probably have to come up with some other form of semi-persistent server-side storage.

Apologies if someone else has done something like this already - if they have I didn't find it. I did find an old fork that did something like this (used the cache to store the most recent AJAX request and load that), but nothing that added a panel and allowed debugging multiple AJAX requests at once, which is probably a necessity in most cases.

Anyways, looking forward to your feedback. Thanks!


This idea has been brought up before, and I like the concept a lot. I'm also not sure the session is the right place to store it. Someone else suggested memcache, which seems a bit more bearable.

Jazzband member

I was just about to implement exactly that, woot! I agree with @dcramer that putting this in a cache (preferable in an own cache backend, falling back to the default one) with the str(uuid.uuid4())-key as the cache key should be better than straining the session API to do the same thing. For local development purposes the locmem backend is totally able to handle that kind of data, too.


Thanks for the feedback guys. I think your suggestion to use the cache sounds good. @jezdez I'm not quite sure what you mean by its own cache backend though? I'd hoped to have some code ready when I replied, but I've been completely swamped this week and haven't had a chance to do anything yet. I'll try to work on these improvements soon and update the pull request accordingly.

Jazzband member

@tobiasmcnulty Oh, I meant that the CACHES setting now can be configured to have multiple backends to have different setup, e.g. using locmem in development and different memcache servers in production:

    'default': {
        'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
        'LOCATION': '',
    'debug_toolbar': {
        'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
        'LOCATION': 'debug_toolbar',
        'TIMEOUT': 60,

Later in the code we could check if a debug_toolbar cache has been configured and fall back to the default cache if not:

from django.core.cache import (get_cache, cache as default_cache,

    debug_toolbar_cache = get_cache('debug_toolbar')
except InvalidCacheBackendError:
    # Use the default backend
    debug_toolbar_cache = default_cache

@tobiasmcnulty Keep in mind that when looking at the toolbar for a specific AJAX request there should still be an easy way to get back to the original page's toolbar. I believe as it stands this only allows switching between other AJAX requests once inside one's toolbar.


@tobiasmcnulty Thanks for getting this started! I would love to have this working, have there been any recent updates? I tried using the posted changes, but now my toolbar does not show up. Any ideas? Thanks.


Sorry, I've not had the time to polish this off - feel free to give it a whirl if you'd like!

@zifot zifot added a commit to zifot/django-debug-toolbar that referenced this pull request Feb 18, 2013
@tobiasmcnulty tobiasmcnulty First shot at ajax requests panel
This is a rebase+squash of the original commits by Tobias McNulty (@tobiasmcnulty),
taken from pull request jazzband/django-debug-toolbar#253, with some
minor changes to resolve merge conflicts.
@zifot zifot referenced this pull request Feb 18, 2013

Another take on AJAX panel #356

Jazzband member

Closing in favor of #356.

@jezdez jezdez closed this Apr 23, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment