K
K
Konstantin Malyarov2018-02-10 21:25:55
Django
Konstantin Malyarov, 2018-02-10 21:25:55

Why forgive the correct format of the DataTime field?

model.py

enterDateTime = models.DateTimeField(blank=True, null=True)

form.py
enterDateTime = forms.DateTimeField(widget=forms.DateTimeInput(
        attrs={'class': 'btn btn-sm btn-outline-primary bg-light col-8 text-dark', 'style': 'text-align: left',
               'type': 'datetime-local'}), required=False)

view.py
formAddForm003y_str1 = addForm003y_str1(request.POST or None, initial={'surName': patient.surName,
                                                                           'firstName': patient.firstName,
                                                                           'secondName': patient.secondName,
                                                                           'dateOfBirth': datetime.strftime(
                                                                               patient.dateOfBirth, "%Y-%m-%d"),
                                                                           'enterDateTime': format(datetime.today(),
                                                                                                   '%Y-%m-%dT%H:%M'),
                                                                           'sex': patient.sex,
                                                                           'diagnosis_directed': inpatientcard.protocolOfCommission.diagnosis,
                                                                           'diagnosis_entered': inpatientcard.protocolOfCommission.diagnosis,
                                                                           'diagnosis': inpatientcard.protocolOfCommission.diagnosis,
                                                                           'mkb': inpatientcard.protocolOfCommission.mkb})

index.html <- str1.html (this is the form that is inserted into the index)
{{ formAddForm003y_str1.enterDateTime.errors }}
    <label for="{{ formAddForm003y_str1.enterDateTime.id_for_label }}"
           class="col-3">Дата и время поступления:</label>
    {{ formAddForm003y_str1.enterDateTime }}

When submitting the form, it gives the following warning:
Please enter the correct date and time.
Why does it arise?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Dimonchik, 2018-02-10
@Konstantin18ko

turn on debugging in sessions and look at the logs
at a glance - you don't have seconds

I
IrkDesigner, 2012-04-03
@IrkDesigner

If the monitor is no longer under warranty, you can disassemble it yourself. First of all, with this inclusion, the fuse should have burned out. It is not difficult to replace it yourself, and its price is 10 rubles, no more ... If the monitor is under warranty, do not hesitate to contact the service center.

A
AxisPod, 2012-04-03
@AxisPod

Apparently, carry it to the service, in the non-native one there could be a different polarity, insufficiently rectified voltage, etc ... It is likely that the thread burned out.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question