These are not golden rules but for reference only.
.save()so it won’t fail.
.save()stays closely with the model definitions.
By default, Django adds the auto-incrementing primary key to each model when we do not specify a custom primary key field.
id = models.AutoField(primary_key=True)
It is beneficial most of the time since the ID is generated by the database and automatically increases according to the available values, so we do not need to worry about setting the value by ourselves and having colliding IDs.
But sometimes we would like to have another unique but not auto-incrementing value as the identifier, serving as a “pseudo primary key” and hiding the actual ID in the database. …
Altering your data models or schema is sometimes inexorable due to changing requirements or fixing legacy design mistakes. It can be a risky refactoring task since the data models are the core of the application, which is also stateful and one would need to take care of compatibility. We also need to be mindful to avoid any customer data loss and minimize the downtime as much as possible.
With the help of ORM frameworks such as Django, modifying database schema is getting easier since the framework can automatically generate SQL migration scripts like
ALTER COLUMN or
Passing props between components is inevitable when writing React applications. But have you ever wonder:
Should the parent component pass the domain entity/object or just the ID of the object into the child component?
And how would this affect the boundaries of smart vs. dumb components?
There are a lot of great articles covering this pattern and illustrating the advantages. I have also briefly mentioned the concept of smart and dumb components in my previous post, but let’s do a quick recap here.
In the early days, class components have been doing the heavy-lifting works such as data fetching, state…
In this post, I would like to share a brief history of ReactJS and its solutions to state management. You may probably know these already, but I think it would give a glimpse of how React evolves all the way long for those who are new to this framework, or a quick refresh if you are a veteran.
React has two types of components — Class-based and Functional. As the names suggest, class components inherit
Software Engineer | Hongkonger 🇭🇰 Passion for Craftsmanship