django-tawkto is a simple Django app to it integrates with https://www.tawk.to/ chat.
Python 3.7 to 3.10 supported.
Django 2.2 to 4.0 supported.
Install the stable release from pypi (using pip):
pip install django-tawktoAdd tawkto to your INSTALLED_APPS setting like this:
INSTALLED_APPS = [
...
'tawkto',
]Add TAWKTO_ID_SITE in settings.py:
TAWKTO_ID_SITE='<tawkto id site>'(Optional) Add TAWKTO_API_KEY:
TAWKTO_API_KEY='<tawkto api key>'(Optional) For secure site (requires TAWKTO_API_KEY):
TAWKTO_IS_SECURE=TrueIn HTML:
{% load tawkto_tags %}
<!DOCTYPE html>
<html lang="en">
<head>
...
</head>
<body>
...
{% tawkto_script %}
</body>
</html>
(Optional) Add visitor name and email:
{% tawkto_script user_name=request.user.get_full_name user_email=request.user.email %}
(Optional) Use a different widget for a given property (default is the default value):
TAWKTO_WIDGET_ID = "default"or
{% tawkto_script widget_id='somewidgetid' %}
(Optional) Use a different tawkto property:
{% tawkto_script id_site='tawktosideit' api_key='tawktoapikey'%}
(Optional) If you want to hide the chat for superuser (default is True):
TAWKTO_EXCLUDE_SUPERUSERS = True(Optional) Set custom metadata regarding this chat/visitor:
is_securemust beTrue.- You must provide a valid email.
- Metadata is represented by key and value.
- The key is of the string data type and can contain only alphanumeric characters and ‘-‘ (dash).
- More in https://developer.tawk.to/jsapi/
setAttributessection.
# view.py
def view(request):
context = {'metadata': {'attr-1': 'value1', 'attr-2': 'value2'}}
return render(request, 'template.html', context)In template:
{% tawkto_script is_secure=True [email protected] extra_attributes=metadata %}
