Django Validation Report (DVR) allows you to control whether all model instances can be resaved without errors.
Suppose you have a Model:
```py
class Person(models.Model):
is_monastic = models.BooleanField()
monastic_name = models.CharField(max_length=100, blank=True)
```
Later on, after there are already some Person objects in the database, you add a `clean` method to the model:
```py
def clean(self):
if self.is_monastic and not self.monastic_name:
raise ValidationError(
"If a Person is monastic, 'monastic_name' must be specified")
```
Now, it would be nice to control whether the old Person objects meet new standards. Otherwise unexpected ValidationErrors might be risen if the old ones are being resaved.
Django Validation Report offers a solution to this problem.
## Features
DVR provides:
1. a report view for logged in users
2. a `manage.py` command to show the report on the console
3. automatic report email sending to admins; this is designed to be addded to your CI/CD script
## Requirements
- Python 3
- Django 2 (should aslo work with previous versions, but it hasn't been tested. See issue [#1](https://github.com/eeriksp/django-validation-report/issues/1))
## Installation
Install using pip:
```
pip install django-validation-report
```
Then add `validation_report` to your INSTALLED_APPS.
```py
INSTALLED_APPS = [
...
'validation_report.apps.ValidationReportConfig',
]
```
To your main `urls.py` add:
```py
urlpatterns = [
...
path('validation-report/', include('validation_report.urls')),
]
```
Also make sure you have specified `LOGIN_URL` in your `settings.py`. In order to see the generated report, the user must be logged in. If you do not have a custom login page, you can just use the default admin login page `LOGIN_URL = '/admin/login/'`.
The emails are sent to `settings.ADMINS`, so check that this constant has been specified and email sending has been configured.
## Usage
### View
Go to `/validation-report/` URL. As a logged in user, you should see something like this:
```
Validation report
Run full_clean() for all Django model instances and return a report regarding failures.
Validating 'Person' with id '1' raised [ValidationError(["If a Person is monastic, 'monastic_name' must be specified"])]
Validating 'Person' with id '3' raised [ValidationError(["If a Person is monastic, 'monastic_name' must be specified"])]
Task completed, 2 errors detected
```
If an error occurred and the server stopped delivering the `StreamingHttpResponse` before all model instances were checked, an error message will be shown:
```
Validation report
Run full_clean() for all Django model instances and return a report regarding failures.
Validating 'Person' with id '1' raised [ValidationError(["If a Person is monastic, 'monastic_name' must be specified"])]
ERROR: Task was not completed, server response was interrupted.
```
### `Manage.py` command
Type
```
$ ./manage.py validationreport
```
The given report is similar to the one returned by the view in the previous chapter.
### Email sending
Type
```
$ ./manage.py validationreport --sendmail
```
You should see something like this:
```
Run `full_clean()` for all Django model instances and return a report regarding failures.
Validating 'Person' with id '1' raised [ValidationError(["If a Person is monastic, 'monastic_name' must be specified"])]
Validating 'Person' with id '3' raised [ValidationError(["If a Person is monastic, 'monastic_name' must be specified"])]
Task completed, 2 errors detected
The report was sent to the following addresses:
abbot@monastery.eu
```
This command is especially useful for adding to your CI/CD script, so you will be notified on time and all possible confusion can be avoided.
## License
DVR is published under MIT license.
Inspired by [SQLite developers](https://www.sqlite.org/different.html), we add the following blessing:
>May you do good and not evil\
May you find forgiveness for yourself and forgive others\
May you share freely, never taking more than you give.
Metadata
Release files for django-validation-report 1.0.3
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 |
|---|---|---|---|---|
| django-validation-report-1.0.3.tar.gz | 6.4 kB | Without provenance | Details for django-validation-report-1.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_validation_report-1.0.3-py3-none-any.whl | Python 3 | none | any | Details for django_validation_report-1.0.3-py3-none-any.whl |
Total release size: 15.1 kB
Release files / django-validation-report-1.0.3.tar.gz
| Download URL | django-validation-report-1.0.3.tar.gz |
|---|---|
| Size | 6.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
39029c31e1daf611a5c80e1fd43b46fb58c3a59f39c36ba92816bb869d94d799
|
|
BLAKE2b-256 checksum How to use checksums |
28b9aa36e19f9b22ae1f870be89ed54c79af83413dcd2c46e09490b5acc98706
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.2
|
Release files / django_validation_report-1.0.3-py3-none-any.whl
| Download URL | django_validation_report-1.0.3-py3-none-any.whl |
|---|---|
| Size | 8.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1457220c09fc960803e21fc064074637fc9701338ddba9fe6a5b42adda725ab4
|
|
BLAKE2b-256 checksum How to use checksums |
239564db706cb1f30015b1b625026a95102184ee9790ecc8d1080340c6d99d78
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.2
|
Security for django-validation-report 1.0.3
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.