Skip to content

Conversation

@Chiemezuo
Copy link
Member

Description

This PR adds the Django Channels' demo Chat app into the Debug Toolbar's example app for easy testing. This is in line to support async and show the Debug Toolbar's compatibility with Django Channels

Fixes #2202

Checklist:

  • I have added the relevant tests for this change.
  • I have added an item to the Pending section of docs/changes.rst.

@Chiemezuo
Copy link
Member Author

@tim-schilling I wasn't entirely sure whether to include the tests for the example app itself, seeing as it is something for testing, rather than a change to the Debug Toolbar itself. I was also unsure of the location to add the test.

@JohananOppongAmoateng
Copy link
Contributor

@Chiemezuo I think we should add it to give the users of the example app that the code in there works as expected

@Chiemezuo
Copy link
Member Author

@JohananOppongAmoateng I think that's an excellent idea. The test requires selenium though. Would it be too much overhead? Since it has to simulate a browser environment.

@tim-schilling tim-schilling removed the request for review from okotdaniel October 14, 2025 18:17
Comment on lines +27 to +29
"websocket": AllowedHostsOriginValidator(
AuthMiddlewareStack(URLRouter(websocket_urlpatterns))
),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is why the toolbar doesn't work with the channels' consumers. When you send a chat message via the websocket, that message isn't visible in the toolbar anywhere. Only the HTTP requests are. It bypasses the middleware that the toolbar works with.

To start, we would need to define a another middleware that is a subclass of channels.middleware.BaseMiddleware. There may be other issues that arise after that. However, I think this is enough for us to declare the toolbar doesn't support Django Channels' consumers yet 😢

Copy link
Member

@tim-schilling tim-schilling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for doing all this! It really helps me see why it doesn't work and where the changes need to go.

So we have a choice to make. We can integrate this proactively, or we can store put this on an issue to make use of in the future when we ship a properly working channels consumer integration. If we don't have immediate plans to work on it, then I would vote for putting all the code in an issue and/or reference this branch so another can continue. However, if someone is planning on working on it in the next few months, then I'm good with merging it.

We will need to update the Django Channels & Async section of the docs at a minimum. It should mention that the toolbar will not work with any Consumer views since it bypasses the Django middleware for the ASGI application.

@tim-schilling
Copy link
Member

@Chiemezuo I think in our meeting last week, we indicated we were going to shelve these changes on an issue. Does that sound right?

I think closing the PR and referring to your branch as long as you don't delete it, would be good. The next step was to create a new PR off of main that updates the documentation in the architecture.rst file to mention that the toolbar doesn't work with Channels' consumers.

@Chiemezuo
Copy link
Member Author

Yes @tim-schilling I just wanted to wrap up this PR properly, even though it would end up shelved. To not leave out any bits incase work continues on it later on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Django Channels integration to example app

3 participants