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

Issue#28 #30

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions bootstrap3_datetime/widgets.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-
import datetime

from django.forms.util import flatatt
from django.forms.widgets import DateTimeInput
from django.utils import translation
Expand Down Expand Up @@ -128,6 +130,8 @@ def render(self, name, value, attrs=None):
input_attrs = self.build_attrs(attrs, type=self.input_type, name=name)
if value != '':
# Only add the 'value' attribute if a value is non-empty.
if isinstance(value, datetime.time):
value = datetime.datetime(2014, 11, 25, value.hour, value.minute, value.second) # any date with value time
input_attrs['value'] = force_text(self._format_value(value))
input_attrs = dict([(key, conditional_escape(val)) for key, val in input_attrs.items()]) # python2.6 compatible
if not self.picker_id:
Expand Down