Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #211 -- edit_inline_type is deprecated, in favor of edit_inline…

… itself. For example, instead of 'edit_inline=True, edit_inline_type=meta.TABULAR', use 'edit_inline=meta.TABULAR'.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@440 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 4f00611f747b566cb7586f02462e57829424f077 1 parent e79eb09
@adrianholovaty adrianholovaty authored
View
2  django/core/meta/__init__.py
@@ -291,7 +291,7 @@ def get_all_related_objects(self):
# 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
View
25 django/core/meta/fields.py
@@ -15,7 +15,7 @@
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 @@ def __init__(self, to, to_field=None, rel_name=None, **kwargs):
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 @@ def __init__(self, to, to_field=None, rel_name=None, **kwargs):
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 @@ def __init__(self, to, to_field=None, rel_name=None, **kwargs):
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 @@ def __init__(self, to, name, field_name, num_in_admin=3, min_num_in_admin=None,
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 @@ def __init__(self, to, name, num_in_admin=0, related_name=None,
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
View
6 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('<fieldset class="module%s">\n' % ((rel_field.rel.edit_inline_type != meta.TABULAR) and ' aligned' or ''))
+ t.append('<fieldset class="module%s">\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 %%}<a href="/r/{{ %s.content_type_id }}/{{ %s.original.id }}/">View on site</a>{%% 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('<h2>%s</h2>\n<table>\n' % capfirst(rel_obj.verbose_name_plural))
t.append('<thead><tr>')
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('<h2>%s #{{ forloop.counter }}</h2>' % capfirst(rel_obj.verbose_name))
if view_on_site:
View
2  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),
View
13 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
View
8 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
Please sign in to comment.
Something went wrong with that request. Please try again.