diff --git a/RoutesApp/forms.py b/RoutesApp/forms.py index 1b67574..9fd301f 100644 --- a/RoutesApp/forms.py +++ b/RoutesApp/forms.py @@ -23,6 +23,9 @@ class RouteForm(forms.ModelForm): try: + if 'departure_DT' in cleaned_data and 'arrival_DT' in cleaned_data and cleaned_data['arrival_DT'] < cleaned_data['departure_DT']: + self.add_error('arrival_DT', _('Указана неверная дата прибытия')) + if 'from_place' in self.data and self.data['from_place'] not in [item[0] for item in self.fields['from_place'].choices]: cleaned_data['from_place'] = self.fields['from_place'].choices[0][0] diff --git a/templates/blocks/profile/b_new_route.html b/templates/blocks/profile/b_new_route.html index d0795ed..4b2a114 100644 --- a/templates/blocks/profile/b_new_route.html +++ b/templates/blocks/profile/b_new_route.html @@ -83,7 +83,7 @@ id="id_departure_DT" name="departure_DT" placeholder="{% translate "Выберите дату и время" %}" {% if form.initial.departure_DT %} - value="{{ form.initial.departure_DT|date:"y.m.d H:m" }}"{% endif %}/> + value="{{ form.initial.departure_DT|date:"d.m.Y H:m" }}"{% endif %}/>
{% if not errors_off and form.errors and form.errors.departure_DT %} @@ -112,7 +112,7 @@ id="id_arrival_DT" name="arrival_DT" placeholder="{% translate "Выберите дату и время" %}" {% if form.initial.arrival_DT %} - value="{{ form.initial.arrival_DT|date:"y.m.d H:m" }}"{% endif %}/> + value="{{ form.initial.arrival_DT|date:"d.m.Y H:m" }}"{% endif %}/>
{# end #}