diff options
| author | Adrian Holovaty <adrian@holovaty.com> | 2005-07-21 03:46:16 +0000 |
|---|---|---|
| committer | Adrian Holovaty <adrian@holovaty.com> | 2005-07-21 03:46:16 +0000 |
| commit | c21f6ecee24c6587bb8ddddc878aad3fd29b40a7 (patch) | |
| tree | c419bdcc72c6e001a58dda127035474cf1800973 /django | |
| parent | 304b08e3254f7c46999d1204ce9968c00ad088eb (diff) | |
Fixed #92 -- meta.Admin 'fields' parameter is now optional. If it's not given, Django will use all editable fields by default. This cuts down on redundancy. Also updated relevant docs to reflect the change.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@265 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
| -rw-r--r-- | django/core/meta.py | 15 | ||||
| -rw-r--r-- | django/models/auth.py | 3 | ||||
| -rw-r--r-- | django/models/core.py | 3 |
3 files changed, 11 insertions, 10 deletions
diff --git a/django/core/meta.py b/django/core/meta.py index 189114219d..5c8d070f40 100644 --- a/django/core/meta.py +++ b/django/core/meta.py @@ -2136,7 +2136,7 @@ class OneToOne(ManyToOne): self.raw_id_admin = raw_id_admin class Admin: - def __init__(self, fields, js=None, list_display=None, list_filter=None, date_hierarchy=None, + def __init__(self, fields=None, js=None, list_display=None, list_filter=None, date_hierarchy=None, save_as=False, ordering=None, search_fields=None, save_on_top=False): self.fields = fields self.js = js or [] @@ -2148,10 +2148,17 @@ class Admin: self.save_on_top = save_on_top def get_field_objs(self, opts): - # Returns self.fields, except with fields as Field objects instead of - # field names. + """ + Returns self.fields, except with fields as Field objects instead of + field names. If self.fields is None, defaults to putting every + non-AutoField field with editable=True in a single fieldset. + """ + if self.fields is None: + field_struct = ((None, {'fields': [f.name for f in opts.fields + opts.many_to_many if f.editable and not isinstance(f, AutoField)]}),) + else: + field_struct = self.fields new_fieldset_list = [] - for fieldset in self.fields: + for fieldset in field_struct: new_fieldset = [fieldset[0], {}] new_fieldset[1].update(fieldset[1]) admin_fields = [] diff --git a/django/models/auth.py b/django/models/auth.py index 4d3f6394a1..516ec112df 100644 --- a/django/models/auth.py +++ b/django/models/auth.py @@ -20,9 +20,6 @@ class Group(meta.Model): ) ordering = (('name', 'ASC'),) admin = meta.Admin( - fields = ( - (None, {'fields': ('name', 'permissions')}), - ), search_fields = ('name',), ) diff --git a/django/models/core.py b/django/models/core.py index 4416f22b76..bdf4567e6a 100644 --- a/django/models/core.py +++ b/django/models/core.py @@ -65,9 +65,6 @@ class Redirect(meta.Model): unique_together=(('site_id', 'old_path'),) ordering = (('old_path', 'ASC'),) admin = meta.Admin( - fields = ( - (None, {'fields': ('site_id', 'old_path', 'new_path')}), - ), list_display = ('__repr__',), list_filter = ('site_id',), search_fields = ('old_path', 'new_path'), |
