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


    "INCLUDE_CAPTCHA" : False,
    "APPS": ["myapp.MyModel"],

run syncdb or migrate to create mailmodel tables:

python migrate mailmodel

Add 'mailmodel.urls' to your

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

To let your users share an object by mail:

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

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.


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


This Page