code: def _get_form_or_formset(self, request, obj, **kwargs):
          
          if self.exclude is None:
              exclude = []
          else:
              exclude = list(self.exclude)
          exclude.extend(self.get_readonly_fields(request, obj))
          if not self.exclude and hasattr(self.form, '_meta') and self.form._meta.exclude:
              # Take the custom ModelForm's Meta.exclude into account only if the
              # ModelAdmin doesn't define its own.
              exclude.extend(self.form._meta.exclude)
          # If exclude is an empty list we pass None to be consistant with the
          # default on modelform_factory
          exclude = self.replace_orig_field(exclude) or None
          exclude = self._exclude_original_fields(exclude)
          kwargs.update({'exclude': exclude})
  
          return kwargs
docs: Generic code shared by get_form and get_formset.