Metadata-Version: 2.1
Name: django_mail_model_template
Version: 0.0.11
Summary: Manage email templates in DB with django
Home-page: https://github.com/dreamiyokoo/django-mail-model-template
Author: Minoru Yokoo
Author-email: yokoo@dreami.jp
License: MIT
Platform: any
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Framework :: Django
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: Django>=3.2
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: pytest-django; extra == "dev"
Requires-Dist: pytest-pythonpath; extra == "dev"
Requires-Dist: tox; extra == "dev"
Requires-Dist: factory_boy; extra == "dev"

# INSTALL

```shell
pip install git+https://github.com/dreamiyokoo/django-mail-model-template.git
```

# Django settings

```python
INSTALLED_APPS = [
...
'django_mail_model_template',
]
```

# Migrations

Migrations are a way of propagating changes you make to your models (adding a field, deleting a model, etc.) into your
database schema. They are designed to be mostly automatic, but you'll need to know when to make migrations, when to run
them, and the common issues you might run into.

You can create migrations for your application using the following command:

```shell
python manage.py makemigrations
```

This command will detect changes made to your models and generate the appropriate migrations.

Once the migrations have been created, you can apply them to your database using:

```shell
python manage.py migrate
```

This command applies the migrations and updates the database schema.

# Viewing Migrations in the Admin

Django's admin interface allows you to view the state of applied migrations. To do this, follow these steps:

1. Log in to the Django admin interface.
2. Navigate to the **"Migrations"** section, which is available under the "Django" admin area.
3. Here, you will be able to see a list of migrations and their states (applied or unapplied).

By using these tools, you can manage the evolution of your database schema in a controlled and predictable way.

# Usage

Register the template either via django-admin or through code.

```python
from django_mail_model_template.models import MailTemplate

MailTemplate.objects.create(
    name="main",
    subject="main subject {{ name }}",
    body="main body {% if name %}{{ name }}{% endif %}",
    html="<p>main html {{ name }}</p>",
)
```

```python
from django_mail_model_template.utils import get_mail_template
params = {"name": "yamada"}
result = get_mail_template("main", params)
```
