|
1 | 1 | <div> |
2 | | - <style> |
3 | | - .dirty { |
4 | | - border: red 1px solid !important; |
5 | | - } |
6 | | - </style> |
| 2 | + <style> |
| 3 | + .dirty { |
| 4 | + border: red 1px solid !important; |
| 5 | + } |
| 6 | + |
| 7 | + </style> |
| 8 | + |
| 9 | + <div> |
| 10 | + <h3>Using unicorn:model with Django models</h3> |
7 | 11 |
|
8 | 12 | <div> |
9 | | - <h3>Using unicorn:model with Django models</h3> |
| 13 | + <div> |
| 14 | + <label>Name</label> |
| 15 | + <input type="text" unicorn:model="flavor.name"></input> |
| 16 | + </div> |
10 | 17 |
|
11 | | - <div> |
12 | | - <div> |
13 | | - <label>Name</label> |
14 | | - <input type="text" unicorn:model="flavor.name"></input> |
15 | | - </div> |
16 | | - |
17 | | - <div> |
18 | | - <label>Label</label> |
19 | | - <input type="text" unicorn:model="flavor.label"></input> |
20 | | - </div> |
| 18 | + <div> |
| 19 | + <label>Label</label> |
| 20 | + <input type="text" unicorn:model="flavor.label"></input> |
| 21 | + </div> |
21 | 22 |
|
22 | | - <button unicorn:click="save_flavor">save_flavor</button> |
| 23 | + <button unicorn:click="save_flavor">save_flavor</button> |
23 | 24 |
|
24 | | - {% for flavor in flavors %} |
25 | | - <div> |
26 | | - <h4>{{ flavor.pk }}</h4> |
27 | | - <label>Name</label> |
28 | | - <input type="text" unicorn:model="flavors.{{ forloop.counter0 }}.name" u:dirty.class="dirty"></input> |
29 | | - {{ flavor.name }} |
30 | | - <br /> |
| 25 | + {% for flavor in flavors %} |
| 26 | + <div> |
| 27 | + <h4>{{ flavor.pk }}</h4> |
| 28 | + <label>Name</label> |
| 29 | + <input type="text" unicorn:model="flavors.{{ forloop.counter0 }}.name" u:dirty.class="dirty"></input> |
| 30 | + {{ flavor.name }} |
| 31 | + <br /> |
31 | 32 |
|
32 | | - <label>Label</label> |
33 | | - <input type="text" unicorn:model="flavors.{{ forloop.counter0 }}.label" u:dirty.class="dirty"></input> |
34 | | - {{ flavor.label }} |
35 | | - <br /> |
| 33 | + <label>Label</label> |
| 34 | + <input type="text" unicorn:model="flavors.{{ forloop.counter0 }}.label" u:dirty.class="dirty"></input> |
| 35 | + {{ flavor.label }} |
| 36 | + <br /> |
36 | 37 |
|
37 | | - <label>Float</label> |
38 | | - <input type="text" unicorn:model="flavors.{{ forloop.counter0 }}.float_value"></input> |
39 | | - {{ flavor.float_value }} |
40 | | - <br /> |
| 38 | + <label>Float</label> |
| 39 | + <input type="text" unicorn:model="flavors.{{ forloop.counter0 }}.float_value"></input> |
| 40 | + {{ flavor.float_value }} |
| 41 | + <br /> |
41 | 42 |
|
42 | | - <label>Decimal value</label> |
43 | | - <input type="text" unicorn:model="flavors.{{ forloop.counter0 }}.decimal_value"></input> |
44 | | - {{ flavor.decimal_value }} |
45 | | - <br /> |
| 43 | + <label>Decimal value</label> |
| 44 | + <input type="text" unicorn:model="flavors.{{ forloop.counter0 }}.decimal_value"></input> |
| 45 | + {{ flavor.decimal_value }} |
| 46 | + <br /> |
46 | 47 |
|
47 | | - <label>Parent</label> |
48 | | - <select unicorn:model="flavors.{{ forloop.counter0 }}.parent"> |
49 | | - <option value="">n/a</option> |
50 | | - {% for available_flavor in available_flavors %} |
51 | | - <option value="{{ available_flavor.pk }}">{{ available_flavor.name }}</option> |
52 | | - {% endfor %} |
53 | | - </select> |
54 | | - {{ flavor.parent.name }} |
55 | | - <br /> |
| 48 | + <label>Parent</label> |
| 49 | + <select unicorn:model="flavors.{{ forloop.counter0 }}.parent"> |
| 50 | + <option value="">n/a</option> |
| 51 | + {% for available_flavor in available_flavors %} |
| 52 | + <option value="{{ available_flavor.pk }}">{{ available_flavor.name }}</option> |
| 53 | + {% endfor %} |
| 54 | + </select> |
| 55 | + {{ flavor.parent.name }} |
| 56 | + <br /> |
56 | 57 |
|
57 | | - <label>Taste</label> |
58 | | - <select unicorn:model="flavors.{{ forloop.counter0 }}.taste_set" multiple> |
59 | | - {% for available_taste in available_tastes %} |
60 | | - <option value="{{ available_taste.pk }}">{{ available_taste.name }}</option> |
61 | | - {% endfor %} |
62 | | - </select> |
| 58 | + <label>Taste</label> |
| 59 | + <select unicorn:model="flavors.{{ forloop.counter0 }}.taste_set" multiple> |
| 60 | + {% for available_taste in available_tastes %} |
| 61 | + <option value="{{ available_taste.pk }}">{{ available_taste.name }}</option> |
| 62 | + {% endfor %} |
| 63 | + </select> |
63 | 64 |
|
64 | | - <ul> |
65 | | - {% for taste in flavor.taste_set.all %} |
66 | | - <li>{{ taste.name }}</li> |
67 | | - {% endfor %} |
68 | | - </ul> |
69 | | - <br /> |
| 65 | + <ul> |
| 66 | + {% for taste in flavor.taste_set.all %} |
| 67 | + <li>{{ taste.name }}</li> |
| 68 | + {% endfor %} |
| 69 | + </ul> |
| 70 | + <br /> |
70 | 71 |
|
71 | | - <button unicorn:click="save({{ forloop.counter0 }})">save(flavor_idx)</button> |
72 | | - <button unicorn:click="delete({{ flavor.pk }})">delete(flavor.pk)</button> |
73 | | - </div> |
74 | | - {% endfor %} |
75 | | - </div> |
| 72 | + <button unicorn:click="save({{ forloop.counter0 }})">save(flavor_idx)</button> |
| 73 | + <button unicorn:click="delete({{ flavor.pk }})">delete(flavor.pk)</button> |
| 74 | + <button u:click="model_typehint({{ flavor.pk }})">model_typehint(flavor.pk)</button> |
| 75 | + </div> |
| 76 | + {% endfor %} |
76 | 77 | </div> |
| 78 | + </div> |
77 | 79 | </div> |
0 commit comments