Skip to main content

Provide Ruby On Rails routing for django

Project description

Ruby on Rails Syntax for Django



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]+"})


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

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

Release history Release notifications

This version
History Node


Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page