Ticket #8899: 8899.exclude-tuple.diff

File 8899.exclude-tuple.diff, 1.8 KB (added by Julien Phalip, 16 years ago)

patch + tests

  • django/django/contrib/admin/options.py

     
    270270        defaults = {
    271271            "form": self.form,
    272272            "fields": fields,
    273             "exclude": exclude + kwargs.get("exclude", []),
     273            "exclude": list(exclude) + list(kwargs.get("exclude", [])),
    274274            "formfield_callback": self.formfield_for_dbfield,
    275275        }
    276276        defaults.update(kwargs)
     
    786786            "formset": self.formset,
    787787            "fk_name": self.fk_name,
    788788            "fields": fields,
    789             "exclude": exclude + kwargs.get("exclude", []),
     789            "exclude": list(exclude) + list(kwargs.get("exclude", [])),
    790790            "formfield_callback": self.formfield_for_dbfield,
    791791            "extra": self.extra,
    792792            "max_num": self.max_num,
  • django/tests/regressiontests/modeladmin/models.py

     
    116116['name']
    117117
    118118
    119 # Using `exclude`.
     119# Using `exclude` as list.
    120120
    121121>>> class BandAdmin(ModelAdmin):
    122122...     exclude = ['bio']
    123123>>> ma = BandAdmin(Band, site)
    124124>>> ma.get_form(request).base_fields.keys()
    125125['name', 'sign_date']
    126  
     126
     127# Using `exclude` as tuple.
     128
     129>>> class BandAdmin(ModelAdmin):
     130...     exclude = ('bio',)
     131>>> ma = BandAdmin(Band, site)
     132>>> ma.get_form(request).base_fields.keys()
     133['name', 'sign_date']
     134
    127135# Using `fields` and `exclude`.
    128136
    129137>>> class BandAdmin(ModelAdmin):
Back to Top