Skip to main content

XMPP integration for Django app made simple

Project description

XMPP integration for Django app made simple!


  • ConverseJS web chat integration

  • Support for MUC auto join

  • Support for users query

  • Ejabberd Django authentication using ejabberd_auth management command

  • Single sign on functionality without storing user’s credentials (requires using ejabberd_auth)

  • Set avatar using gravatar and vCard during first login


Install django-xmpp via pip:

pip install django-xmpp

Add xmpp and django_gravatar into INSTALLED_APPS:


Setup most important variables:


Optionally setup ConverseJS to suit your needs:

    'allow_contact_removal': False,
    'allow_contact_requests': True,
    'auto_subscribe': True,
    'allow_logout': False,
    'allow_muc': True,
    'allow_otr': False,
    'allow_registration': False,
    'message_carbons': True,
    'hide_muc_server': True,
    'use_vcards': True,
    'animate': True,
    'play_sounds': True,
    'xhr_user_search': True,
    'sounds_path': '%ssounds/' % STATIC_URL,
    'visible_toolbar_buttons': {
         'call': False,
         'clear': False,
         'emoticons': True,
         'toggle_participants': False,

Include xmpp.urls in your

urlpatterns = [
    url(r'^xmpp/', include("xmpp.urls")),

Use ConverseJS in your base template:

{% load xmpp_tags %}
{% conversejs_initialize %}

Ejabberd Django authentication

Create file that will simply call ejabberd_auth management command. Adjust to suit your environment (eg. virtualenv):

cd <path_to_your_django_project>
python ejabberd_auth $@

Edit ejabberd.yml and add external auth script, eg.:

        auth_method: external
        extauth_program: "/<path_to_your_project>/"


These are all available settings you may use.


URL for ConverseJS BOSH connection


Default XMPP domain


Domain for multi user chats (default converence.<XMPP_DOMAIN>)


Authentication type for ConverseJS (prebind is not supported so login is the only option)


dictionary of settings passed to converse.initialize. For more list of available options see Converse.js docs


Enable or disable XMPP at all


Enable or disable vCard update


Update vCard every n hours (default False)

A note on usernames

Jabber IDs are case-insensitive (so “” and “” are the same account). By contrast, the username field in the default Django User model is case-sensitive (see this Django ticket). This means two separate “MyUser” and “myuser” accounts in Django will have the same JID on the XMPP server. The ejabberd_auth management command will not authenticate such users, and they will both see “Authentication failed” in Converse and other XMPP clients.

To avoid such conflicts, it is recommended to use a custom User model that enforces unique lowercase usernames with a RegexField. Other characters not allowed in a Jabber ID should be excluded as well. See this guide for details.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-xmpp-0.4.tar.gz (453.1 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page