Step 3 : Filtering¶
In this step we will add end-user filtering using simple parameter fields.
The list window with our products now has a new button in its toolbar. Clicking on this button toggles an additional panel, the parameter panel, to expand or collapse.
We add a new database model "Category"
We add some database fields (delivery_unit, price)
We add more demo data so that there is something to filter
To activate the code of this step in your contributor environment:
$ go lets $ git checkout step3
To see what we changed since the previous step:
$ git diff step2
Not many explanations here yet. Try to understand the code changes and ask questions.
delivery_unitfield is a choicelist field. This is similar to a
ForeignKey, but instead of pointing to a database row, it points to a choice in a hard-coded table, which we call a choicelist. See Introduction to choicelists.
Model.get_simple_parametersmethod (a class method on a database model) yields the name of database fields to be used as "table parameters", i.e. the fields that appear in the "parameter panel" (the panel that expands and collapses when you hit the button). See Introduction to actor parameters.