Changes between Version 19 and Version 20 of NewformsAdminBranch


Ignore:
Timestamp:
Apr 9, 2007, 3:09:14 PM (18 years ago)
Author:
Baptiste <baptiste.goupil@…>
Comment:

Fixing the wrong new example & some explanations about the change of prepopulated_fields location

Legend:

Unmodified
Added
Removed
Modified
  • NewformsAdminBranch

    v19 v20  
    153153=== Changed prepopulate_from to be defined in the Admin class, not database field classes ===
    154154
    155 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:
     155As 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. This change was made to separate the content of models with the presentation of admin : models represent structures of tables, and shouldn't be spoilt by admin stuff. Here's an example comparing old syntax and new syntax:
    156156
    157157{{{
     
    173173    slug = models.CharField(maxlength=60)
    174174
    175     class Admin:
    176         prepopulated_fields = {'slug': ('first_name', 'last_name')}
     175from django.contrib import admin
     176
     177class MyModelOptions(admin.ModelAdmin):
     178    prepopulated_fields = {'slug': ('first_name', 'last_name')}
     179
     180admin.site.register(MyModel, MyModelOptions)
    177181}}}
    178182
Back to Top