Asp.Net MVC style routing in Django
Posted
by Andrew Hanson
on Stack Overflow
See other posts from Stack Overflow
or by Andrew Hanson
Published on 2010-03-29T16:29:58Z
Indexed on
2010/03/29
16:33 UTC
Read the original article
Hit count: 388
asp.net-mvc
|django
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?
© Stack Overflow or respective owner