Index: django/db/models/fields/__init__.py
===================================================================
--- django/db/models/fields/__init__.py	(revisión: 8776)
+++ django/db/models/fields/__init__.py	(copia de trabajo)
@@ -231,7 +231,7 @@
 
     def get_default(self):
         "Returns the default value for this field."
-        if self.default is not NOT_PROVIDED:
+        if self.has_default():
             if callable(self.default):
                 return self.default()
             return force_unicode(self.default, strings_only=True)
@@ -314,6 +314,8 @@
             kwargs.pop('max_length', None)
         if self.has_default():
             defaults['initial'] = self.get_default()
+            if callable(self.default):
+                defaults['show_hidden_initial'] = True
         defaults.update(kwargs)
         return form_class(**defaults)
 
Index: django/forms/fields.py
===================================================================
--- django/forms/fields.py	(revisión: 8776)
+++ django/forms/fields.py	(copia de trabajo)
@@ -28,7 +28,7 @@
 from django.utils.encoding import smart_unicode, smart_str
 
 from util import ErrorList, ValidationError
-from widgets import TextInput, PasswordInput, HiddenInput, MultipleHiddenInput, FileInput, CheckboxInput, Select, NullBooleanSelect, SelectMultiple, DateTimeInput, TimeInput
+from widgets import TextInput, PasswordInput, HiddenInput, MultipleHiddenInput, FileInput, CheckboxInput, Select, NullBooleanSelect, SelectMultiple, DateTimeInput, TimeInput, SplitHiddenDateTimeWidget
 from django.core.files.uploadedfile import SimpleUploadedFile as UploadedFile
 
 __all__ = (
@@ -59,7 +59,7 @@
     creation_counter = 0
 
     def __init__(self, required=True, widget=None, label=None, initial=None,
-                 help_text=None, error_messages=None):
+                 help_text=None, error_messages=None, show_hidden_initial=False):
         # required -- Boolean that specifies whether the field is required.
         #             True by default.
         # widget -- A Widget class, or instance of a Widget class, that should
@@ -73,9 +73,12 @@
         # initial -- A value to use in this Field's initial display. This value
         #            is *not* used as a fallback if data isn't given.
         # help_text -- An optional string to use as "help text" for this Field.
+        # show_hidden_initial -- Boolean that specifies if is needed to render a
+        #                        hidden widget with initial value after widget.
         if label is not None:
             label = smart_unicode(label)
         self.required, self.label, self.initial = required, label, initial
+        self.show_hidden_initial = show_hidden_initial
         if help_text is None:
             self.help_text = u''
         else:
@@ -840,6 +843,7 @@
         self.widget.choices = self.choices
 
 class SplitDateTimeField(MultiValueField):
+    hidden_widget = SplitHiddenDateTimeWidget
     default_error_messages = {
         'invalid_date': _(u'Enter a valid date.'),
         'invalid_time': _(u'Enter a valid time.'),
Index: django/forms/forms.py
===================================================================
--- django/forms/forms.py	(revisión: 8776)
+++ django/forms/forms.py	(copia de trabajo)
@@ -128,6 +128,12 @@
         """
         return self.prefix and ('%s-%s' % (self.prefix, field_name)) or field_name
 
+    def add_initial_prefix(self, field_name):
+        """
+        Add a 'initial' prefix for checking dynamic initial values
+        """
+        return u'initial-%s' % self.add_prefix(field_name)
+
     def _html_output(self, normal_row, error_row, row_ender, help_text_html, errors_on_separate_row):
         "Helper function for outputting HTML. Used by as_table(), as_ul(), as_p()."
         top_errors = self.non_field_errors() # Errors that should be displayed above all fields.
@@ -245,7 +251,7 @@
         Returns True if data differs from initial.
         """
         return bool(self.changed_data)
-    
+
     def _get_changed_data(self):
         if self._changed_data is None:
             self._changed_data = []
@@ -258,7 +264,13 @@
             for name, field in self.fields.items():
                 prefixed_name = self.add_prefix(name)
                 data_value = field.widget.value_from_datadict(self.data, self.files, prefixed_name)
-                initial_value = self.initial.get(name, field.initial)
+                if not field.show_hidden_initial:
+                    initial_value = self.initial.get(name, field.initial)
+                else:
+                    initial_prefixed_name = self.add_initial_prefix(name)
+                    raw_initial_value = field.hidden_widget().value_from_datadict(self.data,
+                            self.files, initial_prefixed_name)
+                    initial_value = field.clean(raw_initial_value)
                 if field.widget._has_changed(initial_value, data_value):
                     self._changed_data.append(name)
         return self._changed_data
@@ -300,6 +312,7 @@
         self.field = field
         self.name = name
         self.html_name = form.add_prefix(name)
+        self.html_check_name = form.add_initial_prefix(name)
         if self.field.label is None:
             self.label = pretty_name(name)
         else:
@@ -336,7 +349,10 @@
                 data = data()
         else:
             data = self.data
-        return widget.render(self.html_name, data, attrs=attrs)
+        field_html = widget.render(self.html_name, data, attrs=attrs)
+        if self.field.show_hidden_initial:
+            field_html += self.field.hidden_widget().render(self.html_check_name, data)
+        return field_html
 
     def as_text(self, attrs=None):
         """
Index: django/forms/widgets.py
===================================================================
--- django/forms/widgets.py	(revisión: 8776)
+++ django/forms/widgets.py	(copia de trabajo)
@@ -25,7 +25,8 @@
     'HiddenInput', 'MultipleHiddenInput',
     'FileInput', 'DateTimeInput', 'TimeInput', 'Textarea', 'CheckboxInput',
     'Select', 'NullBooleanSelect', 'SelectMultiple', 'RadioSelect',
-    'CheckboxSelectMultiple', 'MultiWidget', 'SplitDateTimeWidget',
+    'CheckboxSelectMultiple', 'MultiWidget',
+    'SplitDateTimeWidget', 'SplitHiddenDateTimeWidget',
 )
 
 MEDIA_TYPES = ('css','js')
@@ -662,3 +663,12 @@
             return [value.date(), value.time().replace(microsecond=0)]
         return [None, None]
 
+class SplitHiddenDateTimeWidget(SplitDateTimeWidget):
+    """
+    A Widget that splits datetime input into two <input type="hidden"> inputs.
+    """
+    def __init__(self, attrs=None):
+        widgets = (HiddenInput(attrs=attrs), HiddenInput(attrs=attrs))
+        super(SplitDateTimeWidget, self).__init__(widgets, attrs)
+
+
Index: tests/modeltests/model_formsets/models.py
===================================================================
--- tests/modeltests/model_formsets/models.py	(revisión: 8776)
+++ tests/modeltests/model_formsets/models.py	(copia de trabajo)
@@ -1,4 +1,6 @@
+from django import forms
 from django.db import models
+import datetime
 
 try:
     sorted
@@ -76,7 +78,17 @@
 class MexicanRestaurant(Restaurant):
     serves_tacos = models.BooleanField()
 
+# models for testing callable defaults (see bug #7975). If you define a model
+# with a callable default value, you cannot rely on the initial value in a
+# form.
+class Person(models.Model):
+    name = models.CharField(max_length=128)
 
+class Membership(models.Model):
+    person = models.ForeignKey(Person)
+    date_joined = models.DateTimeField(default=datetime.datetime.now)
+    karma = models.IntegerField()
+
 __test__ = {'API_TESTS': """
 
 >>> from datetime import date
@@ -553,4 +565,61 @@
 >>> type(_get_foreign_key(MexicanRestaurant, Owner))
 <class 'django.db.models.fields.related.ForeignKey'>
 
+# Use of callable defaults (see bug #7975).
+
+>>> person = Person.objects.create(name='Ringo')
+>>> FormSet = inlineformset_factory(Person, Membership, can_delete=False, extra=1)
+>>> formset = FormSet(instance=person)
+
+# in forms rendering with a form field which model form was containing a
+# callable default value, django puts hidden fields for initial data as well as
+# normal field
+
+>>> form = formset.forms[0] # this formset only has one form
+>>> now = form.fields['date_joined'].initial
+>>> '<input type="hidden" name="initial-membership_set-0-date_joined" value="' in unicode(form['date_joined'])
+True
+
+# test for validation with callable defaults. Validations rely on hidden fields
+
+>>> data = {
+...     'membership_set-TOTAL_FORMS': '1',
+...     'membership_set-INITIAL_FORMS': '0',
+...     'membership_set-0-date_joined': unicode(now.strftime('%Y-%m-%d %H:%M:%S')),
+...     'initial-membership_set-0-date_joined': unicode(now.strftime('%Y-%m-%d %H:%M:%S')),
+... }
+>>> formset = FormSet(data, instance=person)
+>>> formset.is_valid()
+True
+>>> one_day_later = now + datetime.timedelta(days=1)
+>>> filled_data = {
+...     'membership_set-TOTAL_FORMS': '1',
+...     'membership_set-INITIAL_FORMS': '0',
+...     'membership_set-0-date_joined': unicode(one_day_later.strftime('%Y-%m-%d %H:%M:%S')),
+...     'initial-membership_set-0-date_joined': unicode(now.strftime('%Y-%m-%d %H:%M:%S')),
+... }
+>>> formset = FormSet(filled_data, instance=person)
+>>> formset.is_valid()
+False
+
+# now test with split datetime fields
+
+>>> class MembershipForm(forms.ModelForm):
+...     date_joined = forms.SplitDateTimeField(initial=now)
+...     class Meta: model = Membership
+...     def __init__(self, **kwargs):
+...         super(MembershipForm, self).__init__(**kwargs)
+...         self.fields['date_joined'].widget = forms.SplitDateTimeWidget()
+>>> FormSet = inlineformset_factory(Person, Membership, form=MembershipForm, can_delete=False, extra=1)
+>>> data = {
+...     'membership_set-TOTAL_FORMS': '1',
+...     'membership_set-INITIAL_FORMS': '0',
+...     'membership_set-0-date_joined_0': unicode(now.strftime('%Y-%m-%d')),
+...     'membership_set-0-date_joined_1': unicode(now.strftime('%H:%M:%S')),
+...     'initial-membership_set-0-date_joined': unicode(now.strftime('%Y-%m-%d %H:%M:%S')),
+... }
+>>> formset = FormSet(data, instance=person)
+>>> formset.is_valid()
+True
+
 """}
Index: tests/regressiontests/forms/widgets.py
===================================================================
--- tests/regressiontests/forms/widgets.py	(revisión: 8776)
+++ tests/regressiontests/forms/widgets.py	(copia de trabajo)
@@ -1093,7 +1093,7 @@
 >>> w.render('date', datetime.datetime(2007, 9, 17, 12, 51))
 u'<input type="text" name="date" value="2007-09-17 12:51:00" />'
 
-# TimeInput ###############################################################
+# TimeInput ###################################################################
 
 >>> w = TimeInput()
 >>> w.render('time', None)
@@ -1113,5 +1113,18 @@
 We should be able to initialize from a unicode value.
 >>> w.render('time', u'13:12:11')
 u'<input type="text" name="time" value="13:12:11" />'
+
+# SplitHiddenDateTimeWidget ###################################################
+
+>>> w = SplitHiddenDateTimeWidget()
+>>> w.render('date', '')
+u'<input type="hidden" name="date_0" /><input type="hidden" name="date_1" />'
+>>> w.render('date', d)
+u'<input type="hidden" name="date_0" value="2007-09-17" /><input type="hidden" name="date_1" value="12:51:34" />'
+>>> w.render('date', datetime.datetime(2007, 9, 17, 12, 51, 34))
+u'<input type="hidden" name="date_0" value="2007-09-17" /><input type="hidden" name="date_1" value="12:51:34" />'
+>>> w.render('date', datetime.datetime(2007, 9, 17, 12, 51))
+u'<input type="hidden" name="date_0" value="2007-09-17" /><input type="hidden" name="date_1" value="12:51:00" />'
+
 """
 
