You need to set support_microseconds=True on the widget.
https://docs.djangoproject.com/en/stable/ref/forms/widgets/#django.forms.Widget.supports_microseconds
On Sunday, March 25, 2018 at 9:03:18 AM UTC-4, Rafał Szymczuk wrote:
-- https://docs.djangoproject.com/en/stable/ref/forms/widgets/#django.forms.Widget.supports_microseconds
On Sunday, March 25, 2018 at 9:03:18 AM UTC-4, Rafał Szymczuk wrote:
I have problem with updating TimeField in my models - when I want to edit objects using forms/formsets the input field on my site is always cutting microseconds.
I made ex. class with TimeField:Then I made a form:class Participant(models.Model): surname = models.CharField(max_length = 256) name = models.CharField(max_length = 256) birth = models.DateField(blank = True, null = True) entry_time = models.TimeField(blank = True, null = True) ...When I am adding new Participant via my form everything is OK. Value of entry_time is saving in my database (SQLite) with properly format(hours:minutes:seconds.class ParticipantForm(forms.ModelForm ): .... entry_time = forms.TimeField(initial="HH:MM:SS.00" , required = False, widget=forms.TimeInput(format=( '%H:%M:%S.%f'))) ....microseconds). But there is a problem when I want to update my participants using this form or formsets. Data loaded to form is always without microseconds (hours:minutes:seconds).
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c29adb01-f40d-47ff-8ad4-8dba369e7c9d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment