Skip to content
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
11 changes: 10 additions & 1 deletion bootstrap3_datetime/widgets.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
from django import VERSION
from django.forms.utils import flatatt
from django.forms.widgets import DateTimeInput
from django.utils import translation
Expand Down Expand Up @@ -124,7 +125,15 @@ def __init__(self, attrs=None, format=None, options=None, div_attrs=None, icon_a
def render(self, name, value, attrs=None):
if value is None:
value = ''
input_attrs = self.build_attrs(attrs, type=self.input_type, name=name)
_attrs = attrs or {}
default_attrs = {'type': self.input_type, 'name': name}
if VERSION < (1, 11):
input_attrs = self.build_attrs(_attrs, **default_attrs)
else:
# The signature of build_attrs changed in Django 1.11.
# See https://code.djangoproject.com/ticket/28095
_attrs.update(default_attrs)
input_attrs = self.build_attrs(self.attrs, extra_attrs=_attrs)
if value != '':
# Only add the 'value' attribute if a value is non-empty.
input_attrs['value'] = force_text(self._format_value(value))
Expand Down