ConfigurationΒΆ

Add 'mailmodel' to you INSTALLED_APPS, and modify your MAILMODEL_CONFIG settings:

INSTALLED_APPS = (
    ...
    'mailmodel',
)

MAILMODEL_CONFIG = {
    "INCLUDE_CAPTCHA" : False,
    "APPS": ["myapp.MyModel"],
    "PUBLIC_CAPTCHA_KEY": "MY_PUBLIC_RECAPTCHA_KEY",
    "PRIVATE_CAPTCHA_KEY": "MY_PRIVATE_RECAPTCHA_KEY"
}

run syncdb or migrate to create mailmodel tables:

python manage.py migrate mailmodel

Add 'mailmodel.urls' to your urls.py:

(r'^share/', include('mailmodel.urls')),

To let your users share an object by mail:

{% load mailmodel_tags %}
{% mail_model 'event.Event' event.id %}

Now you can customize email templates by adding mailmodel/email_body.txt and mailmodel/email_title.txt to your templates dir, here is the default email_body.txt template:

{{ name }} sent you this mail.
Title: {{ obj.title }}
Url: {{ current_site }}{{ obj.get_absolute_url }}
Message: {{ body }}

All form variables + current object + Site.objects.get_current() are passed to the template,

You can create different email for specific model simply by creating mailmodel/app/model_body.txt into your template dir, ex: mailmodel/event/artist_body.txt.

Warning

django-mailmodel donc check if the current user have the permission to submit the object or not so be sur that all objects of the models included in MAILMODEL_CONFIG["APPS"] are public, otherwise implement your permission layer.

Project Versions

Previous topic

Install django-mailmodel

Next topic

Screenshots

This Page