Ticket #10208: fix_10208.diff

File fix_10208.diff, 1.6 KB (added by Keith Bussell, 16 years ago)

patch with fix and test

  • django/contrib/admin/options.py

     
    318318            fields = flatten_fieldsets(self.declared_fieldsets)
    319319        else:
    320320            fields = None
    321         if self.exclude is None:
     321        if self.exclude is not None:
     322            exclude = list(self.exclude)
     323        elif hasattr(self.form, '_meta') and self.form._meta.exclude is not None:
     324            exclude = list(self.form._meta.exclude)
     325        else:
    322326            exclude = []
    323         else:
    324             exclude = list(self.exclude)
     327           
    325328        defaults = {
    326329            "form": self.form,
    327330            "fields": fields,
  • tests/regressiontests/modeladmin/models.py

     
    187187
    188188>>> band2.delete()
    189189
     190>>> class AdminConcertForm(forms.ModelForm):
     191...     class Meta:
     192...         model = Concert
     193...         exclude = ('transport', )
     194...
     195...     def __init__(self, *args, **kwargs):
     196...         super(AdminConcertForm, self).__init__(*args, **kwargs)
     197
     198>>> class ConcertAdmin(ModelAdmin):
     199...     form = AdminConcertForm
     200
     201>>> ma = ConcertAdmin(Concert, site)
     202>>> ma.get_form(request).base_fields.keys()
     203['main_band', 'opening_band', 'day']
     204
    190205# radio_fields behavior ################################################
    191206
    192207First, without any radio_fields specified, the widgets for ForeignKey
Back to Top