Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/neyer/snout
django url pattern generation via inspection
https://github.com/neyer/snout
Last synced: 13 days ago
JSON representation
django url pattern generation via inspection
- Host: GitHub
- URL: https://github.com/neyer/snout
- Owner: neyer
- Created: 2012-07-20T00:58:26.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2013-08-02T21:55:45.000Z (over 11 years ago)
- Last Synced: 2024-09-20T03:53:50.567Z (about 2 months ago)
- Language: Python
- Homepage:
- Size: 54.7 KB
- Stars: 13
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
#snout
## django url pattern generation via inspection
## what
use `snout` to generate routes for your django apps using inspection, so you can do more interesting things.instead of this:
# breakfast/urls.py
from django.conf.urls import patterns, url
urlpatterns = patterns('',
url(r'^$','breakfast.views.index'),
url(r'^order/$''', 'breakfast.views.order'),
url(r'^waffles/$''', 'breakfast.views.waffles'),
url(r'^sausage/$''', 'breakfast.views.sausage'),
url(r'^toast/(?P\d+)$''', 'breakfast.views.toast'),
)
now you can do this:
# breakfast/urls.py
from breakfast import views
import snout
urlpatterns = snout.make_django_patterns(views)awww yeah
## how
install it like this:
`pip install snout`
`make_django_patterns` creates a route for all functions in the given module, except those starting with "_"
underscores (_) are replaced with dashes (-) because why not?
a view named "index" is given the route "^$" by default
any arguments to your view (other than "requests") are assigned regular expression match groups.
## why
laziness
## who
mark neyer, gentleman coder
BSD