Skip to main content

Simpler URL specification for Django.

Project description

django-simple-url allows developers to specify Django routes without having to learn the complicated intricacies of regular expressions, and is meant as a drop-in replacement of the native Django url function.

Usage

Using django-simple-url is almost the same as using the native Django url function.

# main/urls.py
from django_simple_url import simple_url

from . import views

urlpatterns = [
    simple_url('', views.index),
    simple_url('posts/<int:id>/', views.post),
]

It also works nicely with other apps, like for instance the Django Admin.

# main/urls.py
from django.contrib import admin
from django_simple_url import simple_url

urlpatterns = [
    url('admin/', admin.site.urls),
]

Caveats

It should be noted that even though the type int appears in the syntax <int:post_id>, the value passed to the view is still a string. The int part of the syntax only limits the URLs that are matched, but does not alter the value passed to the view.

Inspiration

The development of this library is inspired by the following post on the Django mailing list: Challenge teaching Django to beginners: urls.py.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-simple-url-0.0.1.tar.gz (2.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_simple_url-0.0.1-py2.py3-none-any.whl (3.3 kB view details)

Uploaded Python 2Python 3

File details

Details for the file django-simple-url-0.0.1.tar.gz.

File metadata

File hashes

Hashes for django-simple-url-0.0.1.tar.gz
Algorithm Hash digest
SHA256 f7c5baebdb5fa9fc1a21ac59db109775fb319d82a766092431965d7b9a8263c8
MD5 9e75c69ae90c712c3ab4d99e97ac153f
BLAKE2b-256 d9e8b05b78894552761d531910ec1b877fb29d558ba4a2037de583dc4a0b35de

See more details on using hashes here.

File details

Details for the file django_simple_url-0.0.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for django_simple_url-0.0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 94fec2213ce813bb7e6bf9fdeb90cc7b90a63c4de0a4fab624b41ca7abde006e
MD5 51c99bf5d38cc7c02f40ceb91dc3e697
BLAKE2b-256 73b516202cccff6561168233651dcdf1444d5da59575f8e05f2d3f6ebc4d1e4b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page