=== modified file 'django/forms/models.py'
--- django/forms/models.py	2008-10-08 17:15:33 +0000
+++ django/forms/models.py	2008-10-08 17:15:54 +0000
@@ -163,18 +163,20 @@
     def __init__(self, options=None):
         super(ModelFormOptions, self).__init__(options)
         self.model = getattr(options, 'model', None)
+        self.formfield_kwargs = getattr(options, 'formfield_kwargs', None)
 
 def create_model_fields(cls, attrs):
     """
     Create a list of form field instances from the option 'model'.
     This is used by the ModelForm metaclass.
     """
-    formfield_callback = attrs.pop('formfield_callback', lambda f: f.formfield())
+    formfield_callback = attrs.pop('formfield_callback', lambda f, **kwargs: f.formfield(**kwargs))
     fields = []
     if cls._meta.model:
+        formfield_kwargs = cls._meta.formfield_kwargs or {}
         for dbfield in cls._meta.model._meta.fields + cls._meta.model._meta.many_to_many:
             if dbfield.editable:
-                formfield = formfield_callback(dbfield)
+                formfield = formfield_callback(dbfield, **formfield_kwargs.get(dbfield.name, {}))
                 if formfield:
                     fields.append((dbfield.name, formfield))
     cls.model_fields = SortedDict(fields)
@@ -354,7 +356,7 @@
     __metaclass__ = ModelFormMetaclass
 
 def modelform_factory(model, form=ModelForm, fields=None, exclude=None, fieldsets=None,
-                       inlines=None, formfield_callback=lambda f: f.formfield()):
+                       inlines=None, formfield_kwargs=None, formfield_callback=lambda f, **kwargs: f.formfield(**kwargs)):
     # HACK: we should be able to construct a ModelForm without creating
     # and passing in a temporary inner class
     class Meta:
@@ -364,6 +366,7 @@
     setattr(Meta, 'fields', fields)
     setattr(Meta, 'exclude', exclude)
     setattr(Meta, 'inlines', inlines)
+    setattr(Meta, 'formfield_kwargs', formfield_kwargs)
     class_name = model.__name__ + 'Form'
     return ModelFormMetaclass(class_name, (form,), {'Meta': Meta,
                               'formfield_callback': formfield_callback})
@@ -468,15 +471,15 @@
             form.fields[self._pk_field.name] = IntegerField(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=lambda f, **kwargs: f.formfield(**kwargs),
                          formset=BaseModelFormSet,
                          extra=1, can_delete=False, can_order=False,
-                         max_num=0, fields=None, exclude=None, fieldsets=None, inlines=None):
+                         max_num=0, fields=None, exclude=None, fieldsets=None, inlines=None, formfield_kwargs=None):
     """
     Returns a FormSet class for the given Django model class.
     """
     form = modelform_factory(model, form=form, fields=fields, exclude=exclude,
-                             fieldsets=fieldsets, inlines=inlines,
+                             fieldsets=fieldsets, inlines=inlines,  formfield_kwargs=formfield_kwargs,
                              formfield_callback=formfield_callback)
     FormSet = formset_factory(form, formset, extra=extra, max_num=max_num,
                               can_order=can_order, can_delete=can_delete)
@@ -566,9 +569,9 @@
 
 def inlineformset_factory(parent_model, model, form=ModelForm,
                           formset=BaseInlineFormSet, fk_name=None,
-                          fields=None, exclude=None, fieldsets=None, inlines=None,
+                          fields=None, exclude=None, fieldsets=None, inlines=None, formfield_kwargs=None,
                           extra=3, can_order=False, can_delete=True, max_num=0,
-                          formfield_callback=lambda f: f.formfield()):
+                          formfield_callback=lambda f, **kwargs: f.formfield(**kwargs)):
     """
     Returns an ``InlineFormSet`` for the given kwargs.
 
@@ -595,6 +598,7 @@
         'fields': fields,
         'exclude': exclude,
         'inlines': inlines,
+        'formfield_kwargs': formfield_kwargs,
         'max_num': max_num,
     }
     FormSet = modelformset_factory(model, **kwargs)

