Now that you have studied some object oriented programming and know a good deal of Python, we should look to how you can apply this knowledge to web programming. Previously, we discussed that you could use Python to simply print the html that you wanted. Printing out your entire webpage with Python is horrendous and difficult to maintain. Sure, you might come up with some clever ways to make it more manageable, but I have a far better solution for you.
Django is an excellent web framework for Python that forces your code to be more easily maintained and has a few other perks. It helps keep your code more maintainable by separating your Python code from your html by using an MVC (model, view, and controller) pattern. Once you follow their tutorials, you’ll start to understand how to separate your code into this pattern. I should mention that your typical MVC views are called templates and your typical MVC controllers are called view, which I find very confusing. But, that’s the majority of my complaints with all of Django.
To be fair, learning Django isn’t very easy and it has several more advanced concepts like ORM (Object-relational mapping) and it is also not the easiest thing to get running. However, as you fight your way through learning these, you will realize that they are pretty common in most other web languages. C# has entity framework, Java and ColdFusion use Hibernate, so you will eventually run into ORM. Essentially, ORM is like using your programming language to interact with a database instead of using SQL.
Anyway, please take some time and go build a website with Django. It will help you understand a fundamental paradigm of web development, MVC, and other important advanced web development concepts. Go forth and learn!
As I’ve said, Django is pretty difficult to learn if you are new to programming. I’d highly recommend getting a book to help you work through it, like the one below.