Skip to main content

Djecorator

Write Django routes in the same style as Flask.

Installation

pip install djecorator

Usage

views.py

from django.shortcuts import render
from djecorator import Route

route = Route()

@route("/")
def index(request):
    return render(request, "index.html")

# With path and name parameters
@route("/about/", name="about_page")
def about(request):
    return render(request, "about.html")

# With login required protection
@route("/dashboard/", login_required=True)
def dashboard(request):
    # Only accessible to authenticated users
    return render(request, "dashboard.html")

urls.py

import views

urlpatterns = [
    ...
]

urlpatterns += views.route.patterns

Features

  • Flask-like routing: Define your routes directly above your view functions
  • Prefixing: Add URL and name prefixes to group related routes
  • Authentication: Protect routes with Django's login_required decorator
  • Class-based views: Works with both function-based and class-based views

Route Parameters

The Route class accepts the following parameters:

  • url_prefix: Prefix added to all URL paths
  • name_prefix: Prefix added to all URL names

The @route() decorator accepts the following parameters:

  • path: The URL path (defaults to the function name)
  • name: The URL name (defaults to the function name)
  • login_required: Whether the view requires authentication (defaults to False)

Example with prefixes

# Create a route with prefixes
admin_route = Route(url_prefix="/admin", name_prefix="admin_")

@admin_route("/users/")
def admin_users(request):
    # This will be available at /admin/users/
    # and have the URL name "admin_users"
    return render(request, "admin/users.html")

@admin_route("/settings/", login_required=True)
def admin_settings(request):
    # This will be available at /admin/settings/
    # and have the URL name "admin_settings"
    # and require login
    return render(request, "admin/settings.html")

Metadata

Release files for djecorator 1.2.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 djecorator 1.2.0
File Size Uploaded Provenance
djecorator-1.2.0.tar.gz 5.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for djecorator 1.2.0
File Interpreter ABI Platform
djecorator-1.2.0-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 8.6 kB

Release files / djecorator-1.2.0.tar.gz

Download URL djecorator-1.2.0.tar.gz
Size 5.4 kB
Tags Source
SHA-256 checksum
How to use checksums
597597a01fe8ebd3604933d06e3edd7a357e6c59f31536f5e515f0bd451bb55f
BLAKE2b-256 checksum
How to use checksums
4342ee30677f5345e57a249617019985194d5ebf6f22957ba605e931b34a22d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.32.3

Release files / djecorator-1.2.0-py2.py3-none-any.whl

Download URL djecorator-1.2.0-py2.py3-none-any.whl
Size 3.2 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
1d977a9fa8ed0f8a2c0619be30a4b14a9f7f8da9f540b8b4852539cced475ce1
BLAKE2b-256 checksum
How to use checksums
34f61951effb9d30980a197bd50c07059ff9e41d77e74be235d0886265ef9a3d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.32.3

Security for djecorator 1.2.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.

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