I've developed my own, but it seems like it's a great enough thing that someone else probably thought of it first and did a better job ;)
The goal is to be able to write, in your myapp/views.py
router = Router(prefix=r'^myapp/')
@router.route(url=r'my/url/here', name="my-great-view")
def myview(request):
return render_to_response("mytemplate.html", {})
And then in urls.py
urlpatterns += myapp.views.router.get_patterns()
And there are several other cool decorator things I've built in (@jsonview for taking a returned dictionary and making a json response, @use_template for taking a returned dictionary and passing it to the defined template as the context...)
It seems like this way makes everything a lot more localized an readable. When looking at a view function you don't have to search around to find what url it belongs to, or what it's "named".
I saw this one djangosnippet, but it's a lot more magic than I'd like, and it doesn't look like it's been generally adopted.
In the event that no one has put together a standard solution, should I clean mine up and submit a pull request to contrib?
- here is what I currently have implemented: magic.py
Edit: if you want multiple urls for the same view:
@router.route(url="my-first-url", kwargs={'foo':'bar'})
@router.route(url="my-second=url", kwargs={'foo':'baz'})
def my_view(...): ...
And of course this doesn't have to be the only way to do it -- the normal urlpatterns way has some nice things about it two, but these two methods are not mutually exclusive.