django-knowledge has built in functionality that sends email alerts to subscribed users when a new response is added or accepted. Users can opt-in or out this alert at the time of posting a question or response.
Further, Users with the flag ‘is_staff’ and the permission to change questions will receive updates when a new question is added.
TODO: They can also opt-in or out after the fact.
By default, alerts are disabled. to enable them, simply add to your settings.py:
KNOWLEDGE_ALERTS = True
Also ensure that the Django site framework is installed and setup properly, otherwise the default links may not work properly.
SITE_ID = 1 INSTALLED_APPS = ( # ... 'django.contrib.sites', # ... )
By default, django-knowledge will greedily send emails via whatever email backend you have set during the request/response cycle. This is likely not desirable: we recommend using something like django-celery-email to delay the task via a queue. No further action is needed if you go this route.
Alternatively, you can specify your own email function where you can introduce your own off request functionality:
KNOWLEDGE_ALERTS_FUNCTION_PATH = 'path.to.your.own.function'
The email function should expect three keyword arguments:
Take a look at knowledge.signals.send_alerts for the original alert function to get an idea how it works.
Note: just to clarify: if you change the email function path setting, you will need to send the alert emails (or any other form of communication) yourself. Our builtin function will no longer act.
We offer three default templates used to render both the subject and message of alert emails:
Emails are sent with both txt and html formats. Simply override these if you want to modify the defaults.