Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TimeField is not working #28

Open
javinievas opened this issue Nov 9, 2014 · 2 comments
Open

TimeField is not working #28

javinievas opened this issue Nov 9, 2014 · 2 comments

Comments

@javinievas
Copy link

If you're using a models.TimeField() and configuring the widget to something like DateTimePicker(options={"format":"HH:mm", "pickDate":False}). Should work.

It does for new objects form, but it does not work for editing an object. It tries to convert the object value to a datetime value, and obviously, that's not possible.

I think this should include some kind of check about if the value is_instance of datetime or time, to make it work in both cases.

@javinievas
Copy link
Author

I've made a workaround creating a

    from django.forms.widgets import DateTimeInput, TimeInput
    [..]
    class TimePicker(TimeInput) 

Making it inherit from TimeInput instead of DateTimeInput, make everything work.
I've also modified the init method to add

     self.options["format"] = "HH:mm"
     self.options["pickDate"] = False

as default options for this kind of widget.

@TyVik
Copy link

TyVik commented Nov 25, 2014

See #30 - it closed you issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants