Ticket #14688: BaseInlineFormset-auto_id.patch

File BaseInlineFormset-auto_id.patch, 1.3 KB (added by vicvicvic, 4 years ago)

Adds auto_id to BaseInlineFormSet

  • django/forms/models.py

    diff --git a/django/forms/models.py b/django/forms/models.py
    index 2f41dbf..8a17dab 100644
    a b def modelformset_factory(model, form=ModelForm, formfield_callback=None, 
    693693class BaseInlineFormSet(BaseModelFormSet):
    694694    """A formset for child objects related to a parent."""
    695695    def __init__(self, data=None, files=None, instance=None,
    696                  save_as_new=False, prefix=None, queryset=None):
     696                 save_as_new=False, prefix=None,
     697                 queryset=None, auto_id='id_%s', **kwargs):
    697698        from django.db.models.fields.related import RelatedObject
    698699        if instance is None:
    699700            self.instance = self.fk.rel.to()
    class BaseInlineFormSet(BaseModelFormSet): 
    709710        if queryset is None:
    710711            queryset = self.model._default_manager
    711712        qs = queryset.filter(**{self.fk.name: backlink_value})
    712         super(BaseInlineFormSet, self).__init__(data, files, prefix=prefix,
    713                                                 queryset=qs)
     713
     714        defaults = {'data': data, 'files': files, 'auto_id': auto_id, 'prefix': prefix, 'queryset': qs}
     715        defaults.update(kwargs)
     716        super(BaseInlineFormSet, self).__init__(**defaults)
    714717
    715718    def initial_form_count(self):
    716719        if self.save_as_new:
Back to Top