Asp.Net MVC style routing in Django
- by Andrew Hanson
I've been programming in Asp.Net MVC for quite some time now and to expand a little bit beyond the .Net world I've recently began learning Python and Django. I am enjoying Django but one thing I am missing from Asp.Net MVC is the automatic routing from my urls to my controller actions.
In Asp.Net MVC I can build much of my application using this single default route:
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = "" } // Parameter defaults
);
In Django I've found myself adding an entry to urls.py for each view that I want to expose which leads to a lot more url patterns than I've become used to in Asp.Net MVC.
Is there a way to create a single url pattern in Django that will handle "[Application]/view/[params]" in a way similar to Asp.Net MVC? Perhaps at the main web site level?