I had this same problem.  I think it is still a problem even after the
fixes marked #5027 and #5917.
I'm a Django newbie, so please forgive me if I'm just confused or if I
have missed any future fixes that address this problem.
Gary Davis

Here's a suggested patch to the SelectDateWidget: (to add lines 2-6,
the ones including, and between, the comments)

    def value_from_datadict(self, data, name):
        #### look first for the data in the 'normal' format
        full_value = data.get(name, None)
        if full_value:
            return full_value
        #### else: look for the individual components
        y, m, d = data.get(self.year_field % name),
data.get(self.month_field % name), data.get(self.day_field % name)
        if y and m and d:
            return '%s-%s-%s' % (y, m, d)
        return None

Here's my test suite:

class OriginalRecipe(forms.Form):
    name=forms.CharField()
    birthday=forms.DateField()

class ExtraCrispy(Form):
    name=forms.CharField()
 
birthday=forms.DateField(widget=SelectDateWidget(years=range(2008,2010)))

test_data = {'name':'Teddy Tester',
'birthday':datetime.date(2008,9,30)}

print "HTML from the 'stock' date widget"
print OriginalRecipe(data=test_data)

print
print "HTML from the SelectDateWidget"
print ExtraCrispy(data=test_data)

#  without the patch above, the ExtraCrispy output has no date values
selected;
#  with the patch, the year, month, and day are selected.


On Apr 1, 9:22 am, "Rocio Figueroa" <[EMAIL PROTECTED]> wrote:
> Hello
> Within a form, a field date:
>
> UserForm = forms.models.form_for_instance(user)
> UserForm.base_fields [ 'record'].widget =SelectDateWidget()
>
> Does not shows the correct value, always shows the value of January 1,
> 2008, showing how to make the correct value
>
> Thanks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to