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!

Advertisements
%d bloggers like this: