Ticket #4305: duplicate_fieldnames.diff
File duplicate_fieldnames.diff, 3.5 KB (added by , 16 years ago) |
---|
-
E:/Software/workspace/django-newforms-admin/django/contrib/admin/options.py
148 148 # doesn't work on ModelAdmin classes yet. 149 149 if self.fieldsets and self.fields: 150 150 raise ImproperlyConfigured('Both fieldsets and fields is specified for %s.' % self.model) 151 # Detect potential duplicate fields in fieldsets declaration. Raise an exception if a duplicate is found. 152 if self.fieldsets: 153 flattened_fieldsets = flatten_fieldsets(self.fieldsets) 154 if len(flattened_fieldsets) > len(sets.Set(flattened_fieldsets)): 155 raise ImproperlyConfigured('There are duplicate field(s) in the fieldsets declaration for %s' % self.model) 151 156 152 157 def formfield_for_dbfield(self, db_field, **kwargs): 153 158 """ -
E:/Software/workspace/django-newforms-admin/tests/regressiontests/modeladmin/models.py
103 103 ['name'] 104 104 105 105 106 107 If there are duplicate fields in the fieldsets declaration, an exception 108 should be raised. 109 >>> class BandAdmin(ModelAdmin): 110 ... fieldsets = [(None, {'fields': ['name', 'name']})] 111 112 >>> ma = BandAdmin(Band, site) 113 Traceback (most recent call last): 114 ... 115 ImproperlyConfigured: There are duplicate field(s) in the fieldsets declaration for <class 'regressiontests.modeladmin.models.Band'> 116 117 118 106 119 If we specify a form, it should use it allowing custom validation to work 107 120 properly. This won't, however, break any of the admin widgets or media. 108 121 -
E:/Software/workspace/django-newforms-admin/AUTHORS
290 290 peter@mymart.com 291 291 pgross@thoughtworks.com 292 292 phaedo <http://phaedo.cx/> 293 Julien Phalip <http://www.julienphalip.com> 293 294 phil@produxion.net 294 295 phil.h.smith@gmail.com 295 296 Gustavo Picon -
E:/Software/workspace/django-newforms-admin/docs/admin.txt
102 102 that isn't an ``AutoField`` and has ``editable=True``, in a single fieldset, 103 103 in the same order as the fields are defined in the model. 104 104 105 ``fieldsets`` should not contain duplicates (a duplicate meaning that a same field 106 appears multiple times in the declaration). If a duplicate is found then an exception 107 will be raised. For example, the following would **not** be valid, as the ``pub_date`` 108 field appears twice:: 109 110 class PollAdmin(admin.ModelAdmin): 111 fieldsets = ( 112 (None, { 113 'fields': ('pub_date', 'question') 114 }), 115 ('Date information', { 116 'fields': ('pub_date',) 117 }), 118 ) 119 105 120 The ``field_options`` dictionary can have the following keys: 106 121 107 122 ``fields``