| 1256 | |
| 1257 | == ModelForms made more like Forms == |
| 1258 | |
| 1259 | This is a very subtle change that will only affect people accessing formfields as attributes on a `ModelForm`. After [8618], this is no longer possible. It has never been possible on a `Form` class and was an oversight for `ModelForm`. For most people, no change is required and templates will work exactly as they did before. |
| 1260 | |
| 1261 | The code change for those affected is |
| 1262 | {{{ |
| 1263 | #!python |
| 1264 | |
| 1265 | class MyForm(forms.ModelForm): |
| 1266 | foo = forms.CharField(...) |
| 1267 | |
| 1268 | myform = MyForm() |
| 1269 | |
| 1270 | # Bad. Don't do this. |
| 1271 | myform.foo # Previously possible on ModelForms, but only worked by accident. |
| 1272 | |
| 1273 | # Good! |
| 1274 | myform['foo'] # Has always worked. Works for Forms and ModelForms. |
| 1275 | }}} |