Ticket #13023: 13023_inlines_patch.diff

File 13023_inlines_patch.diff, 1.8 KB (added by Gabriel Hurley, 14 years ago)

Restores desired behavior without breaking anything else, corrects documentation.

  • AUTHORS

     
    507507    Cheng Zhang
    508508    Glenn Maynard <glenn@zewt.org>
    509509    bthomas
     510    Gabriel Hurley <gabriel@strikeawe.com>
    510511
    511512A big THANK YOU goes to:
    512513
  • django/forms/models.py

     
    687687        return super(BaseInlineFormSet, self).initial_form_count()
    688688
    689689    def total_form_count(self):
     690        # To avoid breaking default behavior of max_num = 0, we can set
     691        # max_num to the queryset length and trigger the limiting effect
     692        # that prevents the creation of new inlines.
     693        if self.max_num == 0 and self.extra == 0:
     694            self.max_num = len(self.get_queryset())
    690695        if self.save_as_new:
    691696            return super(BaseInlineFormSet, self).initial_form_count()
    692697        return super(BaseInlineFormSet, self).total_form_count()
  • docs/ref/contrib/admin/index.txt

     
    10481048
    10491049.. versionadded:: 1.2
    10501050
    1051 Extra forms for inlines will be hidden and replaced with a link to dynamically
    1052 add any number of new inlines for users with Javascript enabled.
     1051A link to dynamically add any number of new inlines will be added to the last
     1052inline form of the formset for users with Javascript enabled. To prevent the
     1053dynamic creation of new inlines (and remove that link), specify a value of 0
     1054for both ``extra`` and ``max_num`` (0 is the default for ``max_num``).
    10531055
    10541056``max_num``
    10551057~~~~~~~~~~~
Back to Top