[Django]-Alternate URL router for Django

4👍

All you need is one line in your urls.py that matches everything, and then just write your handler/dispatcher as a view. That handler does whatever you want based on the parts of the URL….

2👍

I’ve never heard of anyone successfully swapping out Django’s URL routing system. There’s certainly no hook for it – core.handlers.base.BaseHandler.get_response calls urlresolvers.RegexURLResolver directly. Conceivably, you could add a middleware at the bottom of the stack that dispatches to your own URL resolution system and returns the response, thus bypassing the Django system, but it’s a bit kludgy.

If you’re after something more like Rails, you might want to try one of the other frameworks – Pyramid, for example, uses a system of Routes very similar to Rails’. Pyramid is much more pluggable than Django, so you should be able to plug in the Jinja2 templating system, which is based on Django’s. However, there’s no way to use Django’s ORM seperately, so you’d need to use SQLAlchemy (which can be used in a way that’s not massively different).

Leave a comment