mirror of https://github.com/django/django.git
Fixed #8194 (again): correctly focus on the first declared field in the admin. Thanks to fredbartle for catching my silly mistake the first time 'round.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8774 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
8b11341a9a
commit
4f5b0a321d
|
@ -20,9 +20,14 @@ class AdminForm(object):
|
|||
yield Fieldset(self.form, name, **options)
|
||||
|
||||
def first_field(self):
|
||||
if self.form._meta.fields is not None:
|
||||
name = self.form._meta.fields[0]
|
||||
return forms.BoundField(self.form, self.form.fields[name], name)
|
||||
try:
|
||||
fieldset_name, fieldset_options = self.fieldsets[0]
|
||||
field_name = fieldset_options['fields'][0]
|
||||
if not isinstance(field_name, basestring):
|
||||
field_name = field_name[0]
|
||||
return self.form[field_name]
|
||||
except (KeyError, IndexError):
|
||||
pass
|
||||
try:
|
||||
return iter(self.form).next()
|
||||
except StopIteration:
|
||||
|
|
Loading…
Reference in New Issue