When dealing with models with nested relationships, it may initially make sense to serialize them in a nested format. However, you may soon discover that this has a couple of potential issues.
- This structure can result in a lot of duplication in the serialized data, especially for many-to-many relationships.
- Since those objects are nested, you don’t have them all in one place for easy referencing or updating. Working around this requires tedious iteration and transformation.
Continue reading Normalize Your Django REST Serializers
How are houses built? Do you finish the bathroom, with tiled floors, a sink, and even a shower curtain, before you even start on the master bedroom? Of course not. You prepare the site, construct framing for the entire house, finish the exterior, install infrastructure (plumbing, electrical, insulation, etc.), and continue to add detail and flesh out different parts of the house until it is complete.
In this post, I will make the case that this is not only the right way to build a house, but the right way to write software as well. Like a house, software is composed of different parts or components. These components need to come together as soon as possible to facilitate good design, prevent unnecessary rework, and enable a steady, stable progression.
Continue reading Tracer Bullet Programming
When it comes to optimizing an ORM, your greatest weapon is your understanding of how your ORM works under the hood (at least at a high level). This makes understanding all of the rules and guidelines for creating a speedy application much easier. Therefore, I highly recommend reading through the Django docs on the subject at least once. My goal for this post is to condense these tips and tricks into an easily-referenceable compilation, as well as adding some of my own. Also check out my Django ORM Optimization cheat sheet for an even more condensed version.
Continue reading Django ORM Optimization Tips