---
title: Django
description: Learn how to integrate Reloop with Django to send emails.
icon: siDjango
---
> For the complete documentation index, see [llms-docs.txt](/llms-docs.txt) or the site index [llms.txt](/llms.txt). Full docs corpus: [llms-full-docs.txt](/llms-full-docs.txt). Prefer markdown URLs (append `.md`) for agent consumption. Product skill: [skill.md](/skill.md).


# Django Integration

Integrate Reloop into your Django application using the Python SDK.

## Installation

```bash
pip install reloop-email
```

## Setup settings.py

Add your API key to your settings:

```python
# settings.py
import os

RELOOP_API_KEY = os.environ.get("RELOOP_API_KEY", "re_your_api_key_here")
```

## Sending an Email

Use the client within your Django views:

```python
from django.http import JsonResponse
from django.conf import settings
from reloop_email import Reloop

reloop = Reloop(api_key=settings.RELOOP_API_KEY)

def send_email_view(request):
    if request.method == 'POST':
        try:
            result = reloop.mail.send({
                "from": "onboarding@reloop.sh",
                "to": "delivered@resend.dev",
                "subject": "Hello from Django",
                "html": "<p>Congrats on sending your first email via Reloop from Django!</p>",
            })
            if result.email_error:
                raise result.email_error
            return JsonResponse(result.response)
        except Exception as e:
            return JsonResponse({"error": str(e)}, status=500)
```
