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 hashes)

Uploaded Source

Built Distribution

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

Uploaded Python 3

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