Django modelformset is powerful!

I spent two days trying all kinds of non-sense trying to setup a form for entering the temperature profile steps. In the end, it turns out using modelformset is so easy! No need to setup extra form for each model. No need to keep tracking which form is initialized by which object.  Two lines take care of everything!

RecipeSet=modelformset_factory(Recipe,extra=7,max_num=8)
n=RecipeSet(queryset=Recipe.objects.all().order_by(‘step’))

Django rocks!

Don’t repeat yourself, unless with style.

Don’t repeat yourself (DRY)

Every distinct concept and/or piece of data should live in one, and only one, place. Redundancy is bad. Normalization is good.

The framework, within reason, should deduce as much as possible from as little as possible.

In most occasions, repeating is a waste of energy and resources. When we do need to repeat ourselves, we should repeat with style, like Pachelbel’s Canon.

Python is an in…

Python is an interpreted language, which can save you considerable time during program development because no compilation and linking is necessary. The interpreter can be used interactively, which makes it easy to experiment with features of the language, to write throw-away programs, or to test functions during bottom-up program development. It is also a handy desk calculator.

Nice pitch.

%d bloggers like this: