On Feb 19, 3:55 pm, "Collin Grady" <[EMAIL PROTECTED]> wrote: > Define a clean_date_posted to trim the decimals?
But the question is where. After you create the form class with FormClass = forms.models.form_for_instance(anInstance) . . . form = FormClass(request.POST) the form is bound to the data and it can't be changed, and form.is_valid() will hit a validation error because the POST has the datetime with all the decimal places. So, the only place I can think of removing the decimals is after you retrieve anInstance from the database, and before you used to create the form class. And it seems a bad idea to have to modify the database data for this purpose. It seems the problem arises when the form field uses the strptime() method to parse and validate the input. There is no way to specify a format string with decimals. My guess is that the form_for_instance(anInstance) call should trim the decimals automatically, so that the hidden field has the proper data without intervention. However, this would also result in indirect database modification. Perhaps the solution is to override the save() method in the model and trim the decimals there. 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 -~----------~----~----~----~------~----~------~--~---