djeveric
Simple email confirmation for django model instances with
[Django Rest Framework](https://www.django-rest-framework.org/).
## Usage
### Create a model
Create a model class inheriting from `ConfirmableModelMixin` with a `ConfirmationField` and refer to a
`ConfirmationEmail` class like this:
```python
from django.conf import settings
from django.db import models
from djeveric.emails import ConfirmationEmail
from djeveric.fields import ConfirmationField
from djeveric.models import ConfirmableModelMixin
class MyModelConfirmationEmail(ConfirmationEmail):
subject = "Please confirm"
def get_body(self, context):
return f"Use this link to confirm: http://my-frontend/confirm/{self.token}"
def get_recipient(self) -> str:
return self.instance.owner.email
class MyModel(ConfirmableModelMixin, models.Model):
owner = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
is_confirmed = ConfirmationField(email_class=MyModelConfirmationEmail)
```
When unconfirmed instances of the model are saved, djeveric sends a confirmation email to the specified address.
### Create a ViewSet
To actually confirm a viewset, your backend needs a view set using the `ConfirmModelMixin`:
```python
from rest_framework import viewsets
from djeveric.views import ConfirmModelMixin
class MyModelViewSet(ConfirmModelMixin, viewsets.GenericViewSet):
queryset = MyModel.objects
```
On a `POST /api/my-models/{pk}/confirm/` with `{"token": "THE TOKEN"}` as data the model instance will be confirmed.
Metadata
Release files for djeveric 2.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| djeveric-2.3.0.tar.gz | 4.4 kB | Without provenance | Details for djeveric-2.3.0.tar.gz |
Release files / djeveric-2.3.0.tar.gz
| Download URL | djeveric-2.3.0.tar.gz |
|---|---|
| Size | 4.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
32a7f604c5f01ba83851297076331b4913c708612a4db5b6ca888425b4361e8b
|
|
BLAKE2b-256 checksum How to use checksums |
18634618de808cf5caa85072b00ee1f01b04f1ed5169dac16358d6954c4bd655
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.3
|
Security for djeveric 2.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.