Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
Adrian Holovaty authored August 09, 2005
2  django/core/meta/__init__.py
@@ -291,7 +291,7 @@ def get_all_related_objects(self):
291 291
                 # relationship we're adding.
292 292
                 link_field = copy.copy(core.RelatedLink._meta.get_field('object_id'))
293 293
                 link_field.rel = ManyToOne(self.get_model_module().Klass, 'related_links', 'id',
294  
-                    num_in_admin=3, min_num_in_admin=3, edit_inline=True, edit_inline_type=TABULAR,
  294
+                    num_in_admin=3, min_num_in_admin=3, edit_inline=TABULAR,
295 295
                     lookup_overrides={
296 296
                         'content_type__package__label__exact': self.app_label,
297 297
                         'content_type__python_module_name__exact': self.module_name
25  django/core/meta/fields.py
@@ -15,7 +15,7 @@
15 15
 BLANK_CHOICE_DASH = [("", "---------")]
16 16
 BLANK_CHOICE_NONE = [("", "None")]
17 17
 
18  
-# Values for Relation.edit_inline_type.
  18
+# Values for Relation.edit_inline.
19 19
 TABULAR, STACKED = 1, 2
20 20
 
21 21
 RECURSIVE_RELATIONSHIP_CONSTANT = 'self'
@@ -531,13 +531,18 @@ def __init__(self, to, to_field=None, rel_name=None, **kwargs):
531 531
             kwargs['name'] = kwargs.get('name', to_name + '_id')
532 532
             kwargs['verbose_name'] = kwargs.get('verbose_name', to._meta.verbose_name)
533 533
             rel_name = rel_name or to_name
  534
+
  535
+        if kwargs.has_key('edit_inline_type'):
  536
+            import warnings
  537
+            warnings.warn("edit_inline_type is deprecated. Use edit_inline instead.")
  538
+            kwargs['edit_inline'] = kwargs.pop('edit_inline_type')
  539
+
534 540
         kwargs['rel'] = ManyToOne(to, rel_name, to_field,
535 541
             num_in_admin=kwargs.pop('num_in_admin', 3),
536 542
             min_num_in_admin=kwargs.pop('min_num_in_admin', None),
537 543
             max_num_in_admin=kwargs.pop('max_num_in_admin', None),
538 544
             num_extra_on_change=kwargs.pop('num_extra_on_change', 1),
539 545
             edit_inline=kwargs.pop('edit_inline', False),
540  
-            edit_inline_type=kwargs.pop('edit_inline_type', STACKED),
541 546
             related_name=kwargs.pop('related_name', None),
542 547
             limit_choices_to=kwargs.pop('limit_choices_to', None),
543 548
             lookup_overrides=kwargs.pop('lookup_overrides', None),
@@ -573,10 +578,15 @@ def __init__(self, to, to_field=None, rel_name=None, **kwargs):
573 578
         kwargs['verbose_name'] = kwargs.get('verbose_name', 'ID')
574 579
         to_field = to_field or to._meta.pk.name
575 580
         rel_name = rel_name or to._meta.object_name.lower()
  581
+
  582
+        if kwargs.has_key('edit_inline_type'):
  583
+            import warnings
  584
+            warnings.warn("edit_inline_type is deprecated. Use edit_inline instead.")
  585
+            kwargs['edit_inline'] = kwargs.pop('edit_inline_type')
  586
+
576 587
         kwargs['rel'] = OneToOne(to, rel_name, to_field,
577 588
             num_in_admin=kwargs.pop('num_in_admin', 0),
578 589
             edit_inline=kwargs.pop('edit_inline', False),
579  
-            edit_inline_type=kwargs.pop('edit_inline_type', STACKED),
580 590
             related_name=kwargs.pop('related_name', None),
581 591
             limit_choices_to=kwargs.pop('limit_choices_to', None),
582 592
             lookup_overrides=kwargs.pop('lookup_overrides', None),
@@ -586,7 +596,7 @@ def __init__(self, to, to_field=None, rel_name=None, **kwargs):
586 596
 
587 597
 class ManyToOne:
588 598
     def __init__(self, to, name, field_name, num_in_admin=3, min_num_in_admin=None,
589  
-        max_num_in_admin=None, num_extra_on_change=1, edit_inline=False, edit_inline_type=STACKED,
  599
+        max_num_in_admin=None, num_extra_on_change=1, edit_inline=False,
590 600
         related_name=None, limit_choices_to=None, lookup_overrides=None, raw_id_admin=False):
591 601
         try:
592 602
             self.to = to._meta
@@ -596,8 +606,7 @@ def __init__(self, to, name, field_name, num_in_admin=3, min_num_in_admin=None,
596 606
         self.name, self.field_name = name, field_name
597 607
         self.num_in_admin, self.edit_inline = num_in_admin, edit_inline
598 608
         self.min_num_in_admin, self.max_num_in_admin = min_num_in_admin, max_num_in_admin
599  
-        self.num_extra_on_change = num_extra_on_change
600  
-        self.edit_inline_type, self.related_name = edit_inline_type, related_name
  609
+        self.num_extra_on_change, self.related_name = num_extra_on_change, related_name
601 610
         self.limit_choices_to = limit_choices_to or {}
602 611
         self.lookup_overrides = lookup_overrides or {}
603 612
         self.raw_id_admin = raw_id_admin
@@ -621,11 +630,11 @@ def __init__(self, to, name, num_in_admin=0, related_name=None,
621 630
 
622 631
 class OneToOne(ManyToOne):
623 632
     def __init__(self, to, name, field_name, num_in_admin=0, edit_inline=False,
624  
-        edit_inline_type=STACKED, related_name=None, limit_choices_to=None, lookup_overrides=None,
  633
+        related_name=None, limit_choices_to=None, lookup_overrides=None,
625 634
         raw_id_admin=False):
626 635
         self.to, self.name, self.field_name = to._meta, name, field_name
627 636
         self.num_in_admin, self.edit_inline = num_in_admin, edit_inline
628  
-        self.edit_inline_type, self.related_name = edit_inline_type, related_name
  637
+        self.related_name = related_name
629 638
         self.limit_choices_to = limit_choices_to or {}
630 639
         self.lookup_overrides = lookup_overrides or {}
631 640
         self.raw_id_admin = raw_id_admin
6  django/views/admin/main.py
@@ -608,11 +608,11 @@ def _get_template(opts, app_label, add=False, change=False, show_delete=False, f
608 608
     for rel_obj, rel_field in opts.get_inline_related_objects():
609 609
         var_name = rel_obj.object_name.lower()
610 610
         field_list = [f for f in rel_obj.fields + rel_obj.many_to_many if f.editable and f != rel_field]
611  
-        t.append('<fieldset class="module%s">\n' % ((rel_field.rel.edit_inline_type != meta.TABULAR) and ' aligned' or ''))
  611
+        t.append('<fieldset class="module%s">\n' % ((rel_field.rel.edit_inline != meta.TABULAR) and ' aligned' or ''))
612 612
         view_on_site = ''
613 613
         if change and hasattr(rel_obj, 'get_absolute_url'):
614 614
             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)
615  
-        if rel_field.rel.edit_inline_type == meta.TABULAR:
  615
+        if rel_field.rel.edit_inline == meta.TABULAR:
616 616
             t.append('<h2>%s</h2>\n<table>\n' % capfirst(rel_obj.verbose_name_plural))
617 617
             t.append('<thead><tr>')
618 618
             for f in field_list:
@@ -654,7 +654,7 @@ def _get_template(opts, app_label, add=False, change=False, show_delete=False, f
654 654
             t.append('{%% for %s in form.%s %%}\n' % (var_name, rel_obj.module_name))
655 655
             t.extend(hidden_fields)
656 656
             t.append('{% endfor %}\n')
657  
-        else: # edit_inline_type == STACKED
  657
+        else: # edit_inline == STACKED
658 658
             t.append('{%% for %s in form.%s %%}' % (var_name, rel_obj.module_name))
659 659
             t.append('<h2>%s #{{ forloop.counter }}</h2>' % capfirst(rel_obj.verbose_name))
660 660
             if view_on_site:
2  docs/db-api.txt
@@ -20,7 +20,7 @@ Throughout this reference, we'll refer to the following Poll application::
20 20
 
21 21
     class Choice(meta.Model):
22 22
         fields = (
23  
-            meta.ForeignKey(Poll, edit_inline=True, edit_inline_type=meta.TABULAR,
  23
+            meta.ForeignKey(Poll, edit_inline=meta.TABULAR,
24 24
                 num_in_admin=10, min_num_in_admin=5),
25 25
             meta.CharField('choice', maxlength=255, core=True),
26 26
             meta.IntegerField('votes', editable=False, default=0),
13  docs/model-api.txt
@@ -316,16 +316,13 @@ Field Types
316 316
     =======================  ============================================================
317 317
     Argument                 Description
318 318
     =======================  ============================================================
319  
-    ``edit_inline``          If ``True``, this related object is edited
  319
+    ``edit_inline``          If not ``False``, this related object is edited
320 320
                              "inline" on the related object's page. This means
321 321
                              that the object will not have its own admin
322  
-                             interface.
323  
-
324  
-    ``edit_inline_type``     This is either ``meta.TABULAR`` or
325  
-                             ``meta.STACKED`` and controls whether the inline
326  
-                             editable objects are displayed as a table or as
327  
-                             a "stack" of fieldsets.  Defaults to
328  
-                             ``meta.STACKED``.
  322
+                             interface. Use either ``meta.TABULAR`` or ``meta.STACKED``,
  323
+                             which, respectively, designate whether the inline-editable
  324
+                             objects are displayed as a table or as a "stack" of
  325
+                             fieldsets.
329 326
 
330 327
     ``limit_choices_to``     A dictionary of lookup arguments and values (see
331 328
                              the `Database API reference`_) that limit the
8  docs/tutorial02.txt
@@ -242,7 +242,7 @@ Poll object. Let's make that happen.
242 242
 Remove the ``admin`` for the Choice model. Then, edit the ``ForeignKey(Poll)``
243 243
 field like so::
244 244
 
245  
-    meta.ForeignKey(Poll, edit_inline=True, num_in_admin=3),
  245
+    meta.ForeignKey(Poll, edit_inline=meta.STACKED, num_in_admin=3),
246 246
 
247 247
 This tells Django: "Choice objects are edited on the Poll admin page. By
248 248
 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
274 274
 fields for entering related Choice objects. For that reason, Django offers an
275 275
 alternate way of displaying inline related objects::
276 276
 
277  
-    meta.ForeignKey(Poll, edit_inline=True, num_in_admin=3, edit_inline_type=meta.TABULAR),
  277
+    meta.ForeignKey(Poll, edit_inline=meta.TABULAR, num_in_admin=3),
278 278
 
279  
-With that ``edit_inline_type=meta.TABULAR``, the related objects are displayed
280  
-in a more compact, table-based format:
  279
+With that ``edit_inline=meta.TABULAR`` (instead of ``meta.STACKED``), the
  280
+related objects are displayed in a more compact, table-based format:
281 281
 
282 282
 .. image:: http://media.djangoproject.com/img/doc/tutorial/admin12.png
283 283
    :alt: Add poll page now has more compact choices

0 notes on commit 4f00611

Please sign in to comment.
Something went wrong with that request. Please try again.