Answer the question
In order to leave comments, you need to log in
How to override template_names in form widget in Django 1.11?
You need to change the display of the SelectDateWidget date fields - wrap the year, month, day fields in div tags with different classes. In django 1.10 this was done by overriding the render method with a few lines added
output = []
for field in self._parse_date_fmt():
if field == 'year':
output.append('<div class="input-field col s4">' + html['year'] + '</div>')
elif field == 'month':
output.append('<div class="input-field col s5">' + html['month'] + '</div>')
elif field == 'day':
output.append('<div class="input-field col s3">' + html['day'] + '</div>')
return mark_safe('\n'.join(output))
class CustomDateWidget(SelectDateWidget):
def get_template_names(self):
return ['accounts/custom_select_date.html']
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question