Skip to content

Scanners

Scanners provide a standardized way to scan a resource for any potential issues.

Scanning

You can scan any resource that mixed in the ProjectScannerMixin

Make a model scannable

Scan a model

python
from djchecklists.models import CheckList

CheckList.scan(qs=Project.objects.all(), code="new_project")

Add scans to a model

  • Any method on a model that starts with _scan_ will be called.
  • The method should return a dictionary that can be serialized to a CheckListItem

Example

python
class Project(models.Model, ProjectScannerMixin):
    def _scan_invoices_from_last_month_in_draft(self):
        return {
            "name": "Invoices from last month in draft",
            "code": "invoices_from_last_month_in_draft",
            "description": "Check if there are any invoices from last month in draft"
        }