Index: django/forms/models.py
===================================================================
--- django/forms/models.py	(revision 13516)
+++ django/forms/models.py	(working copy)
@@ -150,7 +150,7 @@
             data[f.name] = f.value_from_object(instance)
     return data
 
-def fields_for_model(model, fields=None, exclude=None, widgets=None, formfield_callback=lambda f, **kwargs: f.formfield(**kwargs)):
+def fields_for_model(model, fields=None, exclude=None, widgets=None, formfield_callback=None):
     """
     Returns a ``SortedDict`` containing form fields for the given model.
 
@@ -175,7 +175,12 @@
             kwargs = {'widget': widgets[f.name]}
         else:
             kwargs = {}
-        formfield = formfield_callback(f, **kwargs)
+
+        if formfield_callback is None:
+            formfield = f.formfield(**kwargs)
+        else:
+            formfield = formfield_callback(f, **kwargs)
+
         if formfield:
             field_list.append((f.name, formfield))
         else:
@@ -198,8 +203,7 @@
 
 class ModelFormMetaclass(type):
     def __new__(cls, name, bases, attrs):
-        formfield_callback = attrs.pop('formfield_callback',
-                lambda f, **kwargs: f.formfield(**kwargs))
+        formfield_callback = attrs.pop('formfield_callback', None)
         try:
             parents = [b for b in bases if issubclass(b, ModelForm)]
         except NameError:
@@ -376,7 +380,7 @@
     __metaclass__ = ModelFormMetaclass
 
 def modelform_factory(model, form=ModelForm, fields=None, exclude=None,
-                       formfield_callback=lambda f: f.formfield()):
+                       formfield_callback=None):
     # Create the inner Meta class. FIXME: ideally, we should be able to
     # construct a ModelForm without creating and passing in a temporary
     # inner class.
@@ -658,7 +662,7 @@
             form.fields[self._pk_field.name] = ModelChoiceField(qs, initial=pk_value, required=False, widget=HiddenInput)
         super(BaseModelFormSet, self).add_fields(form, index)
 
-def modelformset_factory(model, form=ModelForm, formfield_callback=lambda f: f.formfield(),
+def modelformset_factory(model, form=ModelForm, formfield_callback=None,
                          formset=BaseModelFormSet,
                          extra=1, can_delete=False, can_order=False,
                          max_num=None, fields=None, exclude=None):
@@ -813,7 +817,7 @@
                           formset=BaseInlineFormSet, fk_name=None,
                           fields=None, exclude=None,
                           extra=3, can_order=False, can_delete=True, max_num=None,
-                          formfield_callback=lambda f: f.formfield()):
+                          formfield_callback=None):
     """
     Returns an ``InlineFormSet`` for the given kwargs.
 
Index: tests/regressiontests/model_forms_regress/tests.py
===================================================================
--- tests/regressiontests/model_forms_regress/tests.py	(revision 13518)
+++ tests/regressiontests/model_forms_regress/tests.py	(working copy)
@@ -250,3 +250,50 @@
         form.is_valid()
         # self.assertTrue(form.is_valid())
         # self.assertEquals(form.cleaned_data['url'], 'http://example.com/test')
+
+
+class FormFieldCallbackTests(TestCase):
+
+    def test_baseform_with_widgets_in_meta(self):
+        """
+        Regression for #13095: Using base forms with widgets
+        defined in Meta should not raise errors.
+        """
+        widget = forms.Textarea()
+
+        class BaseForm(forms.ModelForm):
+            class Meta:
+                model = Person
+                widgets = {'name': widget}
+
+        Form = modelform_factory(Person, form=BaseForm)
+        self.assertTrue(Form.base_fields['name'].widget is widget)
+
+    def test_custom_callback(self):
+        """Test that a custom formfield_callback is used if provided"""
+
+        callback_args = []
+
+        def callback(db_field, **kwargs):
+            callback_args.append((db_field, kwargs))
+            return db_field.formfield(**kwargs)
+
+        widget = forms.Textarea()
+
+        class BaseForm(forms.ModelForm):
+            class Meta:
+                model = Person
+                widgets = {'name': widget}
+
+        _ = modelform_factory(Person, form=BaseForm,
+                              formfield_callback=callback)
+        id_field, name_field = Person._meta.fields
+
+        self.assertEqual(callback_args,
+                         [(id_field, {}), (name_field, {'widget': widget})])
+
+    def test_bad_callback(self):
+        # A bad callback provided by user still gives an error
+        self.assertRaises(TypeError, modelform_factory, Person,
+                          widgets={'name': forms.Textarea()},
+                          formfield_callback=lambda f: f.formfield())
Index: tests/regressiontests/model_formsets_regress/tests.py
===================================================================
--- tests/regressiontests/model_formsets_regress/tests.py	(revision 13518)
+++ tests/regressiontests/model_formsets_regress/tests.py	(working copy)
@@ -1,8 +1,10 @@
-from django.forms.models import modelform_factory, inlineformset_factory
+from django import forms
+from django.forms.models import modelform_factory, inlineformset_factory, modelformset_factory
 from django.test import TestCase
 
 from models import User, UserSite, Restaurant, Manager
 
+
 class InlineFormsetTests(TestCase):
     def test_formset_over_to_field(self):
         "A formset over a ForeignKey with a to_field can be saved. Regression for #10243"
@@ -156,3 +158,61 @@
         # you can create a formset with an instance of None
         form = Form(instance=None)
         formset = FormSet(instance=None)
+
+
+class CustomWidget(forms.CharField):
+    pass
+
+
+class UserSiteForm(forms.ModelForm):
+    class Meta:
+        model = UserSite
+        widgets = {'data': CustomWidget}
+
+
+class Callback(object):
+
+    def __init__(self):
+        self.log = []
+
+    def __call__(self, db_field, **kwargs):
+        self.log.append((db_field, kwargs))
+        return db_field.formfield(**kwargs)
+
+
+class FormfieldCallbackTests(TestCase):
+    """
+    Regression for #13095: Using base forms with widgets
+    defined in Meta should not raise errors.
+    """
+
+    def test_inlineformset_factory_default(self):
+        Formset = inlineformset_factory(User, UserSite, form=UserSiteForm)
+        form = Formset({}).forms[0]
+        self.assertTrue(isinstance(form['data'].field.widget, CustomWidget))
+
+    def test_modelformset_factory_default(self):
+        Formset = modelformset_factory(UserSite, form=UserSiteForm)
+        form = Formset({}).forms[0]
+        self.assertTrue(isinstance(form['data'].field.widget, CustomWidget))
+
+    def assertCallbackCalled(self, callback):
+        id_field, user_field, data_field = UserSite._meta.fields
+        expected_log = [
+            (id_field, {}),
+            (user_field, {}),
+            (data_field, {'widget': CustomWidget}),
+        ]
+        self.assertEqual(callback.log, expected_log)
+
+    def test_inlineformset_custom_callback(self):
+        callback = Callback()
+        inlineformset_factory(User, UserSite, form=UserSiteForm,
+                              formfield_callback=callback)
+        self.assertCallbackCalled(callback)
+
+    def test_modelformset_custom_callback(self):
+        callback = Callback()
+        modelformset_factory(UserSite, form=UserSiteForm,
+                             formfield_callback=callback)
+        self.assertCallbackCalled(callback)
