Skip to main content

Provide Ruby On Rails routing for django

Project description

Ruby on Rails Syntax for Django
==============================


Usage
-----

::

from ror_url import ror_url

urlpatterns = [
ror_url('blog/', index_view, name="index"),
ror_url('blog/:slug', article_view, name="article",
constraints={"slug": "[-\w]+"})
]


About
-----

django_ror_url try to replicate the Ruby on Rail routing syntax for
use with django routing system.

It is currently in alpha state with most but the essential part
missing.

How is it working ?
-------------------

Currently, the ror_url module only provide a single function, ror_url
intended to replace the native django's django.conf.urls.url. There are
two differences between these functions. The ror_url take a segment
based path instead of a regex as its first argument and it also take an
extra argument, constraints.

In the segment based path, the url is split on slash and each resulting
piece is considered a segment. A segment can either be a fixed piece,
like ``blog`` or can be an argument, like ``:slug``.

By default, each argument match any string. That can be changed with
the use of the constraints argument. It is a dict, with argument as key
and regex or flag as values. If a flag is used, it will be replaced by
a corresponding regex.

The currents flags and their corresponding regex are:

==== =====
flag regex
==== =====
str .+
int \d+
==== ====

Project details


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