Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #8194 (again): correctly focus on the first declared field in t…

…he 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
  • Loading branch information...
commit 4f5b0a321d0151cfdb06f31a679b118c29a2f713 1 parent 8b11341
@jacobian jacobian authored
Showing with 8 additions and 3 deletions.
  1. +8 −3 django/contrib/admin/helpers.py
View
11 django/contrib/admin/helpers.py
@@ -20,9 +20,14 @@ def __iter__(self):
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:
Please sign in to comment.
Something went wrong with that request. Please try again.