From fe8e00ae06f618ba001d8b0fea34d7846602bdc6 Mon Sep 17 00:00:00 2001 From: Jacob Kaplan-Moss Date: Thu, 28 Aug 2008 20:48:59 +0000 Subject: [PATCH] Fixed #8194: `AdminForm.first_field` now correctly returns the first field when using custom field orders. git-svn-id: http://code.djangoproject.com/svn/django/trunk@8681 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/contrib/admin/helpers.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/django/contrib/admin/helpers.py b/django/contrib/admin/helpers.py index da0925f4b5..613e63e449 100644 --- a/django/contrib/admin/helpers.py +++ b/django/contrib/admin/helpers.py @@ -20,8 +20,10 @@ class AdminForm(object): yield Fieldset(self.form, name, **options) def first_field(self): - for bf in self.form: - return bf + if self.form._meta.fields is not None: + name = self.form._meta.fields[0] + return forms.BoundField(self.form, self.form.fields[name], name) + return iter(self.form).next() def _media(self): media = self.form.media