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.

The checker follows Django's resolver argument passing for path(), re_path(), nested include() calls, converter and regex captures, positional regex groups, and URL pattern keyword arguments.

For class-based views, it checks the methods selected by as_view() and DRF ViewSet actions, including handlers inherited from user base classes. It uses the same route arguments for each handler. The W001 star-argument warning is not emitted for class-based view handlers because *args and **kwargs are normal in Django generic views.

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.11 5.2
3.12–3.15 5.2, 6.0, 6.1

Supported Python versions follow the Python release cycle: versions are dropped once they reach end-of-life. Django has no upper bound, so new releases install without waiting for a package update.

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.15.0
    hooks:
      - id: django-urlconfchecks

For more information, see the usage documentation.

The usage documentation also includes a ready-to-copy VS Code task.

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
}

The checks include type mismatches (E002 and E005), missing or unexpected view arguments (E003, E004, and E006), too many positional regex arguments (E007), and warnings for star arguments (W001 on function views), unknown converter output types (W002), missing annotations (W003), and optional regex groups without a view default (W004).

Use URLCONFCHECKS_SILENCED_VIEWS for fine-grained silencing. Class-based view handler errors use names such as my_project.views.ArticleView.get; my_project.views.ArticleView.* matches all handlers, and my_project.views.ArticleView matches the whole class. Function-view names keep the existing behavior.

Credits

Metadata

Release files for django-urlconfchecks 0.15.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.15.0
File Size Uploaded Provenance Actions
django_urlconfchecks-0.15.0.tar.gz 57.7 kB With provenance Details for django_urlconfchecks-0.15.0.tar.gz

Built distribution (wheel)

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

Total release size: 99.6 kB

Release files / django_urlconfchecks-0.15.0.tar.gz

Download URL django_urlconfchecks-0.15.0.tar.gz
Size 57.7 kB
Tags Source
SHA-256 checksum
How to use checksums
6abac470143ea046d317589399b8f0939198be34b1250a985479f7e06637d9b2
BLAKE2b-256 checksum
How to use checksums
429a12bd8f268476a8a3f0158a50533b31abd8310bacbedcb4193b88197f0379
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.

Transparency log

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

Download URL django_urlconfchecks-0.15.0-py3-none-any.whl
Size 41.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6e3589946b70a6d12619a1896497e7a321111d37d84f5cf84134e27010ef8f62
BLAKE2b-256 checksum
How to use checksums
22be96e95348bf9e1803237ca0795a9db8e4cd7c52dc889aa2c4ceee13a34233
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.

Transparency log

Security for django-urlconfchecks 0.15.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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for django_urlconfchecks-0.15.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.

Transparency log

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.

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