oscarmlage / django-cruds-adminlte

django-cruds is simple drop-in django app that creates CRUD for faster prototyping
BSD 3-Clause "New" or "Revised" License
424 stars 82 forks source link

TimePickerWidget 24 hour time format not working #86

Closed bgunebakan closed 5 years ago

bgunebakan commented 6 years ago

Hi I am triying to use 24hour format but i cannot handle it.My timefield shows as AM/PM format and i cannot change time.

forms.py

'auction_time': TimePickerWidget( attrs={'format': 'HH:ii', 'icon': 'fa-clock-o'}),

models.py

auction_time = models.TimeField(verbose_name='Auction Time', editable=True,null=True, blank=True)

settings.py

TIME_INPUT_FORMATS = ('%H:%M','%I:%M %p')

bgunebakan commented 5 years ago

timepicker.html

<script>
$(function () {
    $(".timepickerwidget").timepicker({
          showInputs: false,
          use24hours: true,
          showMeridian: false   });
});
</script>

settings.py

TIME_INPUT_FORMATS = ('%H:%M',)
TIME_FORMAT = ('H:i')

problem solved.

luisza commented 5 years ago

See https://github.com/oscarmlage/django-cruds-adminlte/blob/master/demo/demo/settings.py Some useful settings variables.

TIME_FORMAT = 'h:i A' DATETIME_FORMAT = 'm/d/Y H:i:s' DATE_FORMAT = "m/d/Y" TIME_INPUT_FORMATS = ['%I:%M %p']