
Research
/Security News
60 Malicious Ruby Gems Used in Targeted Credential Theft Campaign
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
django-route-decorator
Advanced tools
route
decorator for django viewsSimple things should be simple, complex things should be possible (c)Alan Kay
There is some contradiction between decoupling and DRY principles
in django urls. Why not use flasky @route
decorator to fix this issue?
pip install django-route-decorator
It's compatible with django >= 2.0 only,
because it uses new urls.path
syntax.
Just decorate your views with an instance of Route
:
from route_decorator import Route
route = Route()
@route
def foo_view(request):
# /foo-view
@route
def bar__view(request):
# double underscore means a folder
# /bar/view
And don't forget to add the routes into your urls.py
:
from . import views
urlpatterns += views.route.patterns
Now you have your views binded to /foo-view
and /bar-view
respectively.
You can also get map urlname -> url with route.names
and pass them to
frontend maybe. In our case it would be:
{
'foo_view': '/foo-view',
'bar__view': '/bar/view'
}
You can pass url_prefix
and name_prefix
to route:
route = Router('/api', 'api:')
And also use path
and name
in a decorator:
@route('/baz', 'baz-name')
def baz_view(request):
...
So it would be bind to /api/baz
with name api:baz-name
.
FAQs
A flask-style `route` decorator for django views
We found that django-route-decorator 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.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.
Research
/Security News
Two npm packages masquerading as WhatsApp developer libraries include a kill switch that deletes all files if the phone number isn’t whitelisted.