Metadata-Version: 2.1
Name: django-routify
Version: 0.3.4
Summary: Django-Routify is a package for simple routing Views in the classic Django framework.
Author-email: Vitaliy Popel <popelcompany@gmail.com>
Maintainer-email: Vitaliy Popel <popelcompany@gmail.com>
License: MIT License
        
        Copyright (c) 2024 Vitaliy Popel
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/vitaliypopel/django-routify
Project-URL: Documentation, https://vitaliypopel.github.io/django-routify-docs/homepage
Project-URL: Bug reports, https://github.com/vitaliypopel/django-routify/issues
Project-URL: Source, https://github.com/vitaliypopel/django-routify/
Keywords: django-routify,django routify,django-router,django router,router for django,router,routify
Classifier: Development Status :: 5 - Production/Stable
Classifier: License :: OSI Approved :: MIT License
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Information Technology
Classifier: Framework :: Django
Classifier: Framework :: Django :: 4
Classifier: Framework :: Django :: 4.0
Classifier: Framework :: Django :: 4.1
Classifier: Framework :: Django :: 4.2
Classifier: Framework :: Django :: 5.0
Classifier: Framework :: Django :: 5.1
Classifier: Environment :: Web Environment
Classifier: Topic :: Internet
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
Classifier: Topic :: Internet :: WWW/HTTP :: WSGI
Classifier: Topic :: Internet :: WWW/HTTP :: WSGI :: Application
Classifier: Topic :: Internet :: WWW/HTTP :: WSGI :: Server
Classifier: Topic :: Software Development
Classifier: Topic :: Software Development :: Build Tools
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: System :: Networking
Classifier: Topic :: Utilities
Classifier: Typing :: Stubs Only
Classifier: Typing :: Typed
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Operating System :: Unix
Classifier: Operating System :: POSIX :: Linux
Classifier: Operating System :: MacOS
Classifier: Operating System :: Microsoft :: Windows
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: django>=4.0

# Django-Routify
**Django-Routify** is a lightweight package designed to simplify routing views in the classic Django framework.

With Django-Routify, you no longer need to manually register your views in `urlpatterns` using Django's `path()` function. Instead, the package introduces the `Router` class, allowing you to easily register views using the `@Router.route(url_path=...)` decorator. This approach is similar to what you might already be familiar with from frameworks like Flask, FastAPI, or Django REST Framework (DRF), where views are registered with decorators. This not only makes your code easier to read but also streamlines the process of routing.

Additionally, Django-Routify provides the option to set `auto_trailing_slash=True` when initializing the `Router`. This allows you to write URL paths similar to those in Flask or FastAPI, such as `/hello-world`, which will be automatically translated into the classic Django URL format: `hello-world/`.

Django-Routify supports both `function-based` and `class-based` views, as well as `asynchronous` views, providing flexibility for different project needs. 

## Documentation
Documentation are already available [here](https://vitaliypopel.github.io/django-routify-docs/homepage)!

## Example
For **extended example** with tests visit [examples/example](https://github.com/vitaliypopel/django-routify/tree/main/examples/example).

### Using Django-Routify with Django

~/project/app/views.py:
```python
from django.http import HttpRequest, HttpResponse

from django_routify import Router

router = Router('/app', 'app', auto_trailing_slash=True)


@router.route('/hello-world', methods=['GET']) # or @router.get('/hello-world')
def hello_world(request: HttpRequest) -> HttpResponse:
    return HttpResponse('Hello World!')
```

~/project/app/urls.py:
```python
from django_routify import include_router

from .views import router

urlpatterns = [
    include_router(router),
]
```

### Using classic Django

~/project/app/views.py:
```python
from django.http import HttpRequest, HttpResponse
from django.views.decorators.http import require_http_methods


@require_http_methods(['GET'])
def hello_world(request: HttpRequest) -> HttpResponse:
    return HttpResponse('Hello World!')
```

~/project/app/urls.py:
```python
from django.urls import path, include

from .views import hello_world

app_name = 'app'
urlpatterns = [
    path(
        'app/',
        include(
            [
                path('hello-world/', hello_world, name='hello_world'),
            ]
        ),
    ),
]
```

#### Note:
_The result of these two examples will do the same thing_

## Requirements
- Python 3.8+
- Django 4.0+

## Installation
To install Django-Routify package use the command below in your environment:

- Using `pip`
```shell
pip install django-routify
```

- Using `Poetry`
```shell
poetry add django-routify
```
