Skip to main content

Django UrlConf Checks

django-urlconfchecks logo

pypi python Build Status codecov License

Static checker that keeps your URL patterns and view annotations in sync, using Django’s built-in check framework.

Key features

  • Detects mismatches between URL converters/default kwargs and view annotations (ints, UUIDs, container generics, etc.).
  • Works as a Django system check (manage.py check) or standalone CLI.
  • Honors custom converters and fine-grained silencing per view.
  • Pre-commit friendly; CI-ready with machine-readable output.

Installation

pip install django-urlconfchecks

Compatibility:

Python Django
3.10–3.12 4.2 – <6.1
3.13 5.1.3 – <6.1
3.14 5.2.8 – <6.1

Quick start

  1. Install: pip install django-urlconfchecks

  2. From your project root (where manage.py lives): urlconfchecks

    • Or target a specific module: urlconfchecks --urlconf myproj.urls
  3. Optional: add defaults in pyproject.toml:

    [tool.urlconfchecks]
    quiet = true
    format = "json"
    silenced_views = { "myproj.views.legacy_view" = "E002" }
    

    CLI flags always override these defaults.

Usage

As a Django app

Add django_urlconfchecks to your INSTALLED_APPS list in your settings.py file.

    INSTALLED_APPS = [
    ...
    'django_urlconfchecks',
]

As a command line tool

Run this command from the root of your project, were manage.py is located:

$ urlconfchecks --help

    Usage: urlconfchecks [OPTIONS]

      Check all URLConfs for errors.

    Options:
      --version
      -u, --urlconf PATH    Specify the URLconf to check.
      -q, --quiet           Suppress human-readable output; exit codes still set.
      -f, --format TEXT     Output format. Supported: json.
      --install-completion  Install completion for the current shell.
      --show-completion     Show completion for the current shell, to copy it or
                            customize the installation.
      --help                Show this message and exit.

As a pre-commit hook

Add the following to your .pre-commit-config.yaml file:

  - repo: https://github.com/AliSayyah/django-urlconfchecks
    rev: v0.13.0
    hooks:
      - id: django-urlconfchecks

For more information, see the usage documentation.

What it catches (example)

# urls.py
from django.urls import path

from . import views

urlpatterns = [
    path('articles/<str:year>/', views.year_archive),
    path('articles/<int:year>/<int:month>/', views.month_archive),
    path('articles/<int:year>/<int:month>/<slug:slug>/', views.article_detail),
]
# views.py

def year_archive(request, year: int):
    pass


def month_archive(request, year: int, month: int):
    pass


def article_detail(request, year: int, month: int, slug: str):
    pass

Output:

(urlchecker.E002) For parameter `year`, annotated type int does not match expected `str` from urlconf

JSON (--format json):

{
  "errors": [
    {
      "id": "urlchecker.E002",
      "message": "View myproj.views.year_archive for parameter `year`, annotated type int does not match expected `str` from urlconf",
      "obj": "<URLPattern 'articles/<str:year>/'>",
      "hint": null
    }
  ],
  "warnings": [],
  "total_errors": 1,
  "total_warnings": 0
}

Credits

Metadata

Release files for django-urlconfchecks 0.13.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-urlconfchecks 0.13.0
File Size Uploaded
django_urlconfchecks-0.13.0.tar.gz 43.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-urlconfchecks 0.13.0
File Interpreter ABI Platform
django_urlconfchecks-0.13.0-py3-none-any.whl Python 3 none any Details

Total release size: 80.2 kB

Release files / django_urlconfchecks-0.13.0.tar.gz

Download URL django_urlconfchecks-0.13.0.tar.gz
Size 43.0 kB
Tags Source
SHA-256 checksum
How to use checksums
a3760d5cf7f134736cea51ba61ca633ac08d25779334f7f022391958ae1b6a42
BLAKE2b-256 checksum
How to use checksums
c2557869371455dd96fd93315c09a1c62a4959f914067a6d8803c2b53f76d048
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / django_urlconfchecks-0.13.0-py3-none-any.whl

Download URL django_urlconfchecks-0.13.0-py3-none-any.whl
Size 37.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a9b7db50aa23e819547c8f49fbf3ae15bcf6d91818dd7730e2d4edd127856a4a
BLAKE2b-256 checksum
How to use checksums
86217b41a883f434a7b758fbea8b5d97d412a9838b7bac676fc7b5f28e877db4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release history Release notifications | RSS feed

0.13.1

2 release files

This release

0.13.0 This release

2 release files

0.12.0

2 release files

0.11.0

2 release files

0.10.0

2 release files

0.9.0

2 release files

0.8.0

2 release files

0.7.3

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page