Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Web Framework most like ASP.NET MVC 3

As much as I enjoy building on ASP.NET MVC, it's time to move off Windows.

I'd like to switch to something Python-based with the least amount of pain.

Without discussing the merits of or reasons for switching, which Python web framework is most similar to ASP.NET MVC 3 in terms of architecture?

Architectural Examples

I'm talking about the flow, not the language.

Typical .NET Route

routes.MapRoute( // maps requests at /Product/ to ProductController
    "Products", // Route name
    "Product/{action}/{id}", // URL with parameters
    new { controller = "Product", action = "Index", id = UrlParameter.Optional }
        // Parameter defaults
);

Typical .NET controller

public class ProductController
{
    public ActionResult Index(IndexInputModel inputModel)
    {
        // do something with inputModel ...
        var viewModel = new ProductIndexViewModel()
        {
            Products = productList;
        }
        return View("~/Views/Product/Index.cshtml", viewModel);
    }
    // ...
}

Typical ~/Views/Product/Index.cshtml .NET Razor View

@model ProductIndexViewModel

<h2>Products</h2>
@foreach (var product in Model.Products)
{
    <h3>@product.Title</h3>
    <p>@product.Description</p>
    <span class="price">@product.Price</span>
}
like image 679
Petrus Theron Avatar asked Feb 12 '12 21:02

Petrus Theron


People also ask

Does Python use MVC?

As you already know, Django is a Python web framework. And like most modern framework, Django supports the MVC pattern. First let's see what is the Model-View-Controller (MVC) pattern, and then we will look at Django's specificity for the Model-View-Template (MVT) pattern.

Which framework is best for ASP NET MVC?

If you are an expert at ASP.NET MVC, you need not to spend time on some other complex frameworks but ASP.NET WEBAPI is the best one for you. It works on the same lines as MVC – though it doesn't have System. Web dependency.

Is MVC better than asp net?

MVC provides better support to TDD (Test driven development). TDD is related to the test first programming concepts of extreme programming. It helps us to reduced time in reworks and helps create loosely coupled code. MVC enforces separation that reduces complexity of project structure.


1 Answers

Django has some similarities. But python is not strongly typed as .Net, so I think you are going to see quite a bit of differences, no matter which framework you end up with.

like image 103
Klaus Byskov Pedersen Avatar answered Oct 01 '22 15:10

Klaus Byskov Pedersen