diff --git a/django/core/meta/__init__.py b/django/core/meta/__init__.py index 06c3aca3a6..31a131d29d 100644 --- a/django/core/meta/__init__.py +++ b/django/core/meta/__init__.py @@ -291,7 +291,7 @@ class Options: # relationship we're adding. link_field = copy.copy(core.RelatedLink._meta.get_field('object_id')) link_field.rel = ManyToOne(self.get_model_module().Klass, 'related_links', 'id', - num_in_admin=3, min_num_in_admin=3, edit_inline=True, edit_inline_type=TABULAR, + num_in_admin=3, min_num_in_admin=3, edit_inline=TABULAR, lookup_overrides={ 'content_type__package__label__exact': self.app_label, 'content_type__python_module_name__exact': self.module_name diff --git a/django/core/meta/fields.py b/django/core/meta/fields.py index 26691db057..b90877a54b 100644 --- a/django/core/meta/fields.py +++ b/django/core/meta/fields.py @@ -15,7 +15,7 @@ HORIZONTAL, VERTICAL = 1, 2 BLANK_CHOICE_DASH = [("", "---------")] BLANK_CHOICE_NONE = [("", "None")] -# Values for Relation.edit_inline_type. +# Values for Relation.edit_inline. TABULAR, STACKED = 1, 2 RECURSIVE_RELATIONSHIP_CONSTANT = 'self' @@ -531,13 +531,18 @@ class ForeignKey(Field): kwargs['name'] = kwargs.get('name', to_name + '_id') kwargs['verbose_name'] = kwargs.get('verbose_name', to._meta.verbose_name) rel_name = rel_name or to_name + + if kwargs.has_key('edit_inline_type'): + import warnings + warnings.warn("edit_inline_type is deprecated. Use edit_inline instead.") + kwargs['edit_inline'] = kwargs.pop('edit_inline_type') + kwargs['rel'] = ManyToOne(to, rel_name, to_field, num_in_admin=kwargs.pop('num_in_admin', 3), min_num_in_admin=kwargs.pop('min_num_in_admin', None), max_num_in_admin=kwargs.pop('max_num_in_admin', None), num_extra_on_change=kwargs.pop('num_extra_on_change', 1), edit_inline=kwargs.pop('edit_inline', False), - edit_inline_type=kwargs.pop('edit_inline_type', STACKED), related_name=kwargs.pop('related_name', None), limit_choices_to=kwargs.pop('limit_choices_to', None), lookup_overrides=kwargs.pop('lookup_overrides', None), @@ -573,10 +578,15 @@ class OneToOneField(IntegerField): kwargs['verbose_name'] = kwargs.get('verbose_name', 'ID') to_field = to_field or to._meta.pk.name rel_name = rel_name or to._meta.object_name.lower() + + if kwargs.has_key('edit_inline_type'): + import warnings + warnings.warn("edit_inline_type is deprecated. Use edit_inline instead.") + kwargs['edit_inline'] = kwargs.pop('edit_inline_type') + kwargs['rel'] = OneToOne(to, rel_name, to_field, num_in_admin=kwargs.pop('num_in_admin', 0), edit_inline=kwargs.pop('edit_inline', False), - edit_inline_type=kwargs.pop('edit_inline_type', STACKED), related_name=kwargs.pop('related_name', None), limit_choices_to=kwargs.pop('limit_choices_to', None), lookup_overrides=kwargs.pop('lookup_overrides', None), @@ -586,7 +596,7 @@ class OneToOneField(IntegerField): class ManyToOne: def __init__(self, to, name, field_name, num_in_admin=3, min_num_in_admin=None, - max_num_in_admin=None, num_extra_on_change=1, edit_inline=False, edit_inline_type=STACKED, + max_num_in_admin=None, num_extra_on_change=1, edit_inline=False, related_name=None, limit_choices_to=None, lookup_overrides=None, raw_id_admin=False): try: self.to = to._meta @@ -596,8 +606,7 @@ class ManyToOne: self.name, self.field_name = name, field_name self.num_in_admin, self.edit_inline = num_in_admin, edit_inline self.min_num_in_admin, self.max_num_in_admin = min_num_in_admin, max_num_in_admin - self.num_extra_on_change = num_extra_on_change - self.edit_inline_type, self.related_name = edit_inline_type, related_name + self.num_extra_on_change, self.related_name = num_extra_on_change, related_name self.limit_choices_to = limit_choices_to or {} self.lookup_overrides = lookup_overrides or {} self.raw_id_admin = raw_id_admin @@ -621,11 +630,11 @@ class ManyToMany: class OneToOne(ManyToOne): def __init__(self, to, name, field_name, num_in_admin=0, edit_inline=False, - edit_inline_type=STACKED, related_name=None, limit_choices_to=None, lookup_overrides=None, + related_name=None, limit_choices_to=None, lookup_overrides=None, raw_id_admin=False): self.to, self.name, self.field_name = to._meta, name, field_name self.num_in_admin, self.edit_inline = num_in_admin, edit_inline - self.edit_inline_type, self.related_name = edit_inline_type, related_name + self.related_name = related_name self.limit_choices_to = limit_choices_to or {} self.lookup_overrides = lookup_overrides or {} self.raw_id_admin = raw_id_admin diff --git a/django/views/admin/main.py b/django/views/admin/main.py index c6ff36bf46..78c6161e99 100644 --- a/django/views/admin/main.py +++ b/django/views/admin/main.py @@ -608,11 +608,11 @@ def _get_template(opts, app_label, add=False, change=False, show_delete=False, f for rel_obj, rel_field in opts.get_inline_related_objects(): var_name = rel_obj.object_name.lower() field_list = [f for f in rel_obj.fields + rel_obj.many_to_many if f.editable and f != rel_field] - t.append('
\n' % ((rel_field.rel.edit_inline_type != meta.TABULAR) and ' aligned' or '')) + t.append('
\n' % ((rel_field.rel.edit_inline != meta.TABULAR) and ' aligned' or '')) view_on_site = '' if change and hasattr(rel_obj, 'get_absolute_url'): view_on_site = '{%% if %s.original %%}View on site{%% endif %%}' % (var_name, var_name, var_name) - if rel_field.rel.edit_inline_type == meta.TABULAR: + if rel_field.rel.edit_inline == meta.TABULAR: t.append('

%s

\n\n' % capfirst(rel_obj.verbose_name_plural)) t.append('') for f in field_list: @@ -654,7 +654,7 @@ def _get_template(opts, app_label, add=False, change=False, show_delete=False, f t.append('{%% for %s in form.%s %%}\n' % (var_name, rel_obj.module_name)) t.extend(hidden_fields) t.append('{% endfor %}\n') - else: # edit_inline_type == STACKED + else: # edit_inline == STACKED t.append('{%% for %s in form.%s %%}' % (var_name, rel_obj.module_name)) t.append('

%s #{{ forloop.counter }}

' % capfirst(rel_obj.verbose_name)) if view_on_site: diff --git a/docs/db-api.txt b/docs/db-api.txt index 02faa8a484..40fe40a64d 100644 --- a/docs/db-api.txt +++ b/docs/db-api.txt @@ -20,7 +20,7 @@ Throughout this reference, we'll refer to the following Poll application:: class Choice(meta.Model): fields = ( - meta.ForeignKey(Poll, edit_inline=True, edit_inline_type=meta.TABULAR, + meta.ForeignKey(Poll, edit_inline=meta.TABULAR, num_in_admin=10, min_num_in_admin=5), meta.CharField('choice', maxlength=255, core=True), meta.IntegerField('votes', editable=False, default=0), diff --git a/docs/model-api.txt b/docs/model-api.txt index f071c1bfcb..7b93032919 100644 --- a/docs/model-api.txt +++ b/docs/model-api.txt @@ -316,16 +316,13 @@ Field Types ======================= ============================================================ Argument Description ======================= ============================================================ - ``edit_inline`` If ``True``, this related object is edited + ``edit_inline`` If not ``False``, this related object is edited "inline" on the related object's page. This means that the object will not have its own admin - interface. - - ``edit_inline_type`` This is either ``meta.TABULAR`` or - ``meta.STACKED`` and controls whether the inline - editable objects are displayed as a table or as - a "stack" of fieldsets. Defaults to - ``meta.STACKED``. + interface. Use either ``meta.TABULAR`` or ``meta.STACKED``, + which, respectively, designate whether the inline-editable + objects are displayed as a table or as a "stack" of + fieldsets. ``limit_choices_to`` A dictionary of lookup arguments and values (see the `Database API reference`_) that limit the diff --git a/docs/tutorial02.txt b/docs/tutorial02.txt index b932aea4f0..d084e2b748 100644 --- a/docs/tutorial02.txt +++ b/docs/tutorial02.txt @@ -242,7 +242,7 @@ Poll object. Let's make that happen. Remove the ``admin`` for the Choice model. Then, edit the ``ForeignKey(Poll)`` field like so:: - meta.ForeignKey(Poll, edit_inline=True, num_in_admin=3), + meta.ForeignKey(Poll, edit_inline=meta.STACKED, num_in_admin=3), This tells Django: "Choice objects are edited on the Poll admin page. By default, provide enough fields for 3 Choices." @@ -274,10 +274,10 @@ One small problem, though. It takes a lot of screen space to display all the fields for entering related Choice objects. For that reason, Django offers an alternate way of displaying inline related objects:: - meta.ForeignKey(Poll, edit_inline=True, num_in_admin=3, edit_inline_type=meta.TABULAR), + meta.ForeignKey(Poll, edit_inline=meta.TABULAR, num_in_admin=3), -With that ``edit_inline_type=meta.TABULAR``, the related objects are displayed -in a more compact, table-based format: +With that ``edit_inline=meta.TABULAR`` (instead of ``meta.STACKED``), the +related objects are displayed in a more compact, table-based format: .. image:: http://media.djangoproject.com/img/doc/tutorial/admin12.png :alt: Add poll page now has more compact choices