|
1 | 1 | [[chapter_14_simple_form]]
|
2 | 2 | == A Simple Form
|
3 | 3 |
|
4 |
| -.🚧 Warning, Chapter update in progress |
5 |
| -******************************************************************************* |
6 |
| -This chapter is currently in the process of being rewritten for the 3e. |
7 |
| -
|
8 |
| -The code listings should all be valid, |
9 |
| -and work with Python3.12 + Django 4, |
10 |
| -but I haven't reviewed the chapter text in detail yet. |
11 |
| -
|
12 |
| -******************************************************************************* |
13 |
| - |
14 | 4 |
|
15 | 5 | At the end of the last chapter,
|
16 | 6 | we were left with the thought that there was too much duplication
|
@@ -615,9 +605,8 @@ with `id_text` and `text`, respectively:
|
615 | 605 | $ *grep -r id_new_item src/lists/*
|
616 | 606 | ----
|
617 | 607 |
|
618 |
| -Good, there are no references to `id_new_item` left. |
619 |
| -// CSANAD: we could mention *.pyc files under __pycache__ would probably still |
620 |
| -// show up in the results. |
| 608 | +Good, there are no references to `id_new_item` left--except maybe in some |
| 609 | +`*.pyc` files, which are safe to ignore. |
621 | 610 | What about `name`/ `item_text`?
|
622 | 611 |
|
623 | 612 | [subs="specialcharacters,macros"]
|
@@ -678,6 +667,9 @@ element: .invalid-feedback; [...]
|
678 | 667 | [...]
|
679 | 668 | ----
|
680 | 669 |
|
| 670 | +// TODO re-order the steps for this chapter: it would be better to start with |
| 671 | +// the `id_text` related errors first, and only then fix the validation. |
| 672 | + |
681 | 673 | Let's start with the latter.
|
682 | 674 | Checking _views.py_ and the `new_list` view we can see
|
683 | 675 | it's because if we detect a validation error,
|
@@ -1361,7 +1353,13 @@ Ran 4 tests in 14.367s
|
1361 | 1353 | OK
|
1362 | 1354 | ----
|
1363 | 1355 |
|
1364 |
| -Great! Our two views are now looking very much like "normal" Django views: |
| 1356 | +Great! Let's commit our changes: |
| 1357 | +[subs="specialcharacters,quotes"] |
| 1358 | +---- |
| 1359 | +$ *git commit -am "implement custom save method for the form"* |
| 1360 | +---- |
| 1361 | + |
| 1362 | +Our two views are now looking very much like "normal" Django views: |
1365 | 1363 | they take information from a user's request,
|
1366 | 1364 | combine it with some custom logic or information from the URL (`list_id`),
|
1367 | 1365 | pass it to a form for validation and possible saving,
|
|
0 commit comments