On Fri, 2008-07-04 at 14:17 -0700, mw wrote:
> Hello,
> 
> I get the feeling that this isn't the easiest thing to accomplish
> given the different posts about it on the list, the lack of response
> to questions around in in IRC, and etc, though it strikes me as
> something that should be easy to do
> 
> I want to switch the DateTimeField to having a 12-hr clock input such
> that in places like the admin interface or in your own forms, a user
> could simply type 12:00 a.m.  or have a Jquery plugin help out and let
> them choose 12:00 a.m.  Right now, this will be rejected as a bad
> input.
> 
> I'm having problems finding clear instructions on how to actually make
> this happen.  I wish it was a simple as modifying the DATETIME_FORMAT
> variable in settings.py, but that doesn't do the trick.

There are at least two solutions that immediately jump to mind:

1. Use Javascript to modify the submitted input so that it's converted
from a.m./p.m. to the format the server expects after the form
submission button is pressed and before it is sent to the server. The
drawback here is that when the server returns the data to the form
(either as initial data somewhere or for error reporting), you'll need
to convert it back to 12-hour time.

2. Since the problem you are seeing is simply with field validation, use
different field validation. It is trivial to write your own form fields
-- just have a look at the existing fields in django/newforms/fields.py.
So write a field that has a clean() method which handles the input
formats you like and use that.

Regards,
Malcolm



--~--~---------~--~----~------------~-------~--~----~
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