# Review: Getting Started with Django

reviewdjango

I was quite impressed by the beautiful design of Django when I steered away from the desktop application development to the web development. I felt more at home nowadays with micro framework such as flask since I spent quite a little time in Jinja template and SQLAlchemy ORM in my last two gigs. I was quite delighted when invited to review a Django book: Getting Started with Django to refresh my Django skills.

According to the author, the Book targets to

Python developers who want to learn how to create a website with a quality framework. The book is also for web developers who use other languages such as PHP and who wish to improve the quality and maintainability of their website.

I am afraid this is a uphill battle to please the two camps in one book: they are just too different. You may end up discussing python 101 or web 101 instead of focusing on the framework itself. For example, the author spent several pages in URL mapping introducing regular expression, a common sense for most python developers. I will argue it is a much safer bet to assume the audience with basic knowledge of python development.

The book starts with the overview of the MVC(model, view, and controller), then a canonical Hello world example to showcase the framework. The author keeps refining the TaskManager web application to explore the routing, the template, and the model. I appreciate this approach since the reader can easily get hands dirty without wading through the details.

I was really disappointed by the discussion with the model though. The ER(Entity-relationship) modeling is probably the most challenging and fun part of the web application development. It dictates how the data will be consumed and contributes handsomely to the performance bottleneck. The author barely scratches the surface of this topic:

In chapter 5, Working with Models, the author uses three entities: Project, UserProfile, and Task to model the relationship:

• Project has One-to-Many relationship with Task
• Task has Many-to-One relationship with UserProfile.

It is OK to simplify the relationship for the sake of clarity, but not OK to leave the mystery of the ORM(Object-relational mapping) intact. The ORM is powerful but also opaque. The data access performance is ultimately bound by underlying table design and SQL queries. Without the knowledge of the data access layer how could you troubleshoot and tune the performance? This is especially true for some advanced features such as model inheritance.

When we query the data, not only we use the basic CRUD operation, but we also join tables, commit or rollback transaction atomically etc. None of them is discussed in the chapter 6.

The remaining book also covers the forms, generic views, session, authentication module, AJAX, and production deployment. The author covers pretty much all the bases as a getting-started book, but the content is spread too thin to dive deep. Compared to the official Django tutorial, I don’t see the significant value the book bring to the table.

It is also worthy noting that the author did a slack job on spell check, UserProfile is mistakenly referenced as App_user several times in the model design.

Also the example for pluralize filter is totally wrong:

You have {{ product }} nb_products {{ nb_products | pluralize }} in
our cart.

It really should be:

You have {{ nb_products }} product{{ nb_products | pluralize }} in
our cart.

And the content of the Worker_manager.wsgi file is missing in chapter 12.

## Conclusion

I will not recommend the book for you to get started with Django. Start with the tutorial, and read through the comprehensive Django documentations to dive deep.