Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Django-Routify is a package for simple routing Views in the classic Django framework.
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 are already available here!
For extended example with tests visit examples/example.
~/project/app/views.py:
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:
from django_routify import include_router
from .views import router
urlpatterns = [
include_router(router),
]
~/project/app/views.py:
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:
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'),
]
),
),
]
The result of these two examples will do the same thing
To install Django-Routify package use the command below in your environment:
pip
pip install django-routify
Poetry
poetry add django-routify
FAQs
Django-Routify is a package for simple routing Views in the classic Django framework.
We found that django-routify demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.