code: def get_formset(self, request, obj=None, **kwargs):
          
          if self.declared_fieldsets:
              fields = flatten_fieldsets(self.declared_fieldsets)
          else:
              fields = None
          if self.exclude is None:
              exclude = []
          else:
              exclude = list(self.exclude)
  
          exclude.extend(kwargs.get("exclude", []))
          exclude.extend(self.get_readonly_fields(request, obj))
  
          # if exclude is an empty list we use None, since that's the actual
          # default
          exclude = exclude or None
          defaults = {
              "form": self.form,
              "formset": self.formset,
              "fk_name": self.fk_name,
              "fields": fields,
              "exclude": exclude,
              "formfield_callback": curry(self.formfield_for_dbfield, request=request),
              "extra": self.extra,
              "max_num": self.max_num,
              "can_delete": self.can_delete,
          }
          defaults.update(kwargs)
  
          return inlineformset_factory(self.parent_model, self.model, **defaults)
docs: Returns a BaseInlineFormSet class for use in admin add/change views.