Skip to main content

A simple Django app to route requests, Inspired by Next.js App Router.

Project description

django app router

A modern, easy to use, and powerful router for Django apps. Inspired by the Next.js app router.

Django App Router

Installing

Python 3.12 or higher is required

Windows:

$ pip install -U django-app-router

Linux/MacOS:

$ python3 -m pip install -U django-app-router

Quick Example

<app_name>/urls.py:

from pathlib import Path

import django_app_router

urlpatterns = []

urlpatterns += django_app_router.get_urlpatterns(
    # The path to the templates folder
    Path(__file__).resolve().parent / 'templates',
)

App folder structure:

app
├── __init__.py
├── admin.py
├── apps.py
├── migrations
│   └── __init__.py
├── models.py
├── templates
│   ├── page.html
│   ├── page.py
│   ├── info
│   │   └── page.py
│   └── user
│       └── [user_id]
│           ├── page.html
│           └── page.py
├── tests.py
├── urls.py
└── views.py

Above example will generate the following urlpatterns (approximately):

urlpatterns = [
    path('', views.page, name='home'),
    path('info/', views.info_page, name='info'),
    path('/user/<int:user_id>/', views.user_page, name='get_user'),
]

You can see the full example in the example folder.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-app-router-0.0.1a0.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

django_app_router-0.0.1a0-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file django-app-router-0.0.1a0.tar.gz.

File metadata

  • Download URL: django-app-router-0.0.1a0.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for django-app-router-0.0.1a0.tar.gz
Algorithm Hash digest
SHA256 07f1d44708949a1d0a75be4e75df23c2b78f1d6b5e3b17d21806bf042d7346c7
MD5 12303e7865cd9df675b52a443b9d3e77
BLAKE2b-256 beff5497c86c6ecd8d41faff0e61e974fec04fc02e374ea40873d09bdcec51c9

See more details on using hashes here.

File details

Details for the file django_app_router-0.0.1a0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_app_router-0.0.1a0-py3-none-any.whl
Algorithm Hash digest
SHA256 fd605fa2662f23b0f1f7ac7d6f5644feb1c6429beb9d5cd626b4f4f82b23f952
MD5 3d6fdc4e900a5f637d3a634bdaa432a0
BLAKE2b-256 cead7bfe11e12c3792c4e2e0e66ea483cc36b7df8a74097039f7e5375d1823ee

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page