.. _ref-settings:

==================
Available Settings
==================

Here is a list of all available settings of django-campaign and their
default values. All settings are prefixed with ``CAMPAIGN_``, although this
is a bit verbose it helps to make it easy to identify these settings.


CAMPAIGN_BACKEND
----------------

Default: ``'campaign.backends.send_mail'``

The backend used for the actual sending of the emails. The default backend
``campaign.backends.send_mail`` uses Django's built-in e-mail sending
capabilities.

Additionally the following backend is available:

* ``'campaign.backends.mandrill_api'``: Uses Mandrill for sending the e-mails.

Please see the :ref:`backend docs <ref-backends>` about implementing your
own backend.


CAMPAIGN_CONTEXT_PROCESSORS
---------------------------

Default: ``('campaign.context_processors.recipient',)``

Similar to Django's Template Context Processors these are callables which take
a Subscriber object as their argument and return a dictionary with items to
add to the Template Context which is used to render the Mail.

The following processors are availble within the django-campaign distribution:

* ``recipient``: Implements the old default behaviour and adds the Subscriber
  object (a Django Model instance) to the mail context under the name
  `recipient`.

* ``recipient_dict``: Serializes the Subscriber object to a dict before adding
  it to the context. This is neccesary, if you want to pass per recipient
  variables to a remote service. Use this a basis for your own campaign
  context processors.


CAMPAIGN_SUBSCRIBE_CALLBACK
---------------------------

Default: ``None``

If CAMPAIGN_SUBSCRIBE_CALLBACK is configured the handling of newsletter
subscriptions via django-campaign will be enabled.

You have to supply either a callable or an import-path to a callable, which
accepts an email address as argument and returns either True or False to indicate
if the action was performed successfully.

Example settings.py::

    CAMPAIGN_SUBSCRIBE_CALLBACK = "myproject.newsletter.utils.subscribe"

Example implementation of the callback in your app::

    def subscribe(email):
        s,c = Subscriber.objects.get_or_create(email=email,
                                             defaults={'newsletter': True})
        return True

It's up to you to decide where to store the Subscribers, as django-campaign is
completely agnostic in this point. One or more Subscriber models can be
defined via the admin interface for the :ref:`SubscriberList <ref-concepts>` model.


CAMPAIGN_UNSUBSCRIBE_CALLBACK
-----------------------------

Default: ``None``

Please see CAMPAIGN_SUBSCRIBE_CALLBACK_ above and replace subscribe with
unsubscribe.

