| 613 | |
| 614 | == Changed prepopulate_from to be defined in the Admin class, not database field classes == |
| 615 | |
| 616 | As of [4446], the {{{prepopulate_from}}} option to database fields no longer exists. It's been discontinued in favor of the new {{{prepopulated_fields}}} option on {{{class Admin}}}. The new {{{prepopulated_fields}}} option, if given, should be a dictionary mapping field names to lists/tuples of field names. Here's an example comparing old syntax and new syntax: |
| 617 | |
| 618 | {{{ |
| 619 | #!python |
| 620 | |
| 621 | # OLD: |
| 622 | class MyModel(models.Model): |
| 623 | first_name = models.CharField(maxlength=30) |
| 624 | last_name = models.CharField(maxlength=30) |
| 625 | slug = models.CharField(maxlength=60, prepopulate_from=('first_name', 'last_name')) |
| 626 | |
| 627 | class Admin: |
| 628 | pass |
| 629 | |
| 630 | # NEW: |
| 631 | class MyModel(models.Model): |
| 632 | first_name = models.CharField(maxlength=30) |
| 633 | last_name = models.CharField(maxlength=30) |
| 634 | slug = models.CharField(maxlength=60, prepopulate_from=('first_name', 'last_name')) |
| 635 | |
| 636 | class Admin: |
| 637 | prepopulated_fields = {'slug': ('first_name', 'last_name')} |
| 638 | }}} |
| 639 | |
| 640 | Note that this change was made to the NewformsAdminBranch branch, which is scheduled to merge to trunk by January 31. The change will not be made to trunk until that branch is merged to trunk. |