'Returns a Form class for use in the admin add view. This is used by
add_view and change_view.'

def get_form(self, request, obj=None, **kwargs):

    if ('fields' in kwargs):
        fields = kwargs.pop('fields')
    else:
        fields = flatten_fieldsets(self.get_fieldsets(request, obj))
    if (self.exclude is None):
        exclude = []
    else:
        exclude = list(self.exclude)
    exclude.extend(self.get_readonly_fields(request, obj))
    if ((self.exclude is None) and hasattr(self.form, '_meta') and self.form._meta.exclude):
        exclude.extend(self.form._meta.exclude)
    exclude = (exclude or None)
    defaults = {'form': self.form, 'fields': fields, 'exclude': exclude, 'formfield_callback': partial(self.formfield_for_dbfield, request=request)}
    defaults.update(kwargs)
    if ((defaults['fields'] is None) and (not modelform_defines_fields(defaults['form']))):
        defaults['fields'] = forms.ALL_FIELDS
    try:
        return modelform_factory(self.model, **defaults)
    except FieldError as e:
        raise FieldError(('%s.    Check    fields/fieldsets/exclude    attributes    of    class    %s.' % (e, self.__class__.__name__)))
