id,summary,reporter,owner,description,type,status,component,version,severity,resolution,keywords,cc,stage,has_patch,needs_docs,needs_tests,needs_better_patch,easy,ui_ux 19514,form.fields.keyOrder is not supported for AdminForm,Andrew Scorpil,nobody,"When you have redefined ModelAdmin and redefined ModelForm for change_view/add_view, this form will be modified to AdminForm. In process, django will automatically create fieldset, if it's not already there, by calling get_fieldset (django.contrib.admin.options.py:425): {{{ def get_fieldsets(self, request, obj=None): ""Hook for specifying fieldsets for the add form."" if self.declared_fieldsets: return self.declared_fieldsets form = self.get_form(request, obj) fields = list(form.base_fields) + list(self.get_readonly_fields(request, obj)) return [(None, {'fields': fields})] }}} Obviously, this won't preserve any ordering that may have been specified in __self.fields.keyOrder__. I understand why this was implemented in such a way: keyOrder is specified (in most cases) when form is initialized, and AdminForm is created before that, but it would be great to have ordering functionality in place for django-admin, so i propose to think about the good way to fix this. Steps to reproduce: 1. Create simple model called, for example, '''CustomModel''' 2. Create '''ModelForm''' based on this model. Let's call it '''CustomModelForm'''. 3. In the '''CustomModelForm.!__init!__''' specify something like '''self.fields.keyOrder = self.fields.keyOrder[::-1]''' 4. Create '''CustomModelAdmin''' that inherits '''django.contrib.admin.ModelAdmin''' 5. Set '''form = CustomModelForm''' under '''CustomModelAdmin''' 6. Register '''CustomModel''' and '''CustomModelAdmin''' to the '''admin_site'''. 7. Enter '''change_view''' or '''add_view''' from the browser. Order of fields stays as it is defined in model, while programmer expects it to be reversed.",Bug,closed,contrib.admin,1.4,Normal,wontfix,"keyOrder, form, django-admin",,Unreviewed,0,0,0,0,0,0