forked from mirrors/bookwyrm
Fixes default values in edit announcement form
This commit is contained in:
parent
8b6934d1d0
commit
a70c713c29
2 changed files with 8 additions and 3 deletions
|
@ -2,7 +2,11 @@
|
|||
{% load i18n %}
|
||||
|
||||
{% block header %}
|
||||
{% if announcement %}
|
||||
{% trans "Edit Announcement" %}
|
||||
{% else %}
|
||||
{% trans "Create Announcement" %}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block form %}
|
||||
|
@ -24,7 +28,7 @@
|
|||
</p>
|
||||
<p>
|
||||
<label class="label" for="id_event_date">Event date:</label>
|
||||
<input type="date" name="event_date" value="{{ form.event_date.value }}" class="input" id="id_event_date">
|
||||
<input type="date" name="event_date" value="{{ form.event_date.value|date:'Y-m-d' }}" class="input" id="id_event_date">
|
||||
{% for error in form.event_date.errors %}
|
||||
<p class="help is-danger">{{ error | escape }}</p>
|
||||
{% endfor %}
|
||||
|
@ -34,7 +38,7 @@
|
|||
<div class="column">
|
||||
<p>
|
||||
<label class="label" for="id_start_date">Start date:</label>
|
||||
<input type="date" name="start_date" class="input" id="id_start_date">
|
||||
<input type="date" name="start_date" class="input" value="{{ form.start_date.value|date:'Y-m-d' }}" id="id_start_date">
|
||||
{% for error in form.start_date.errors %}
|
||||
<p class="help is-danger">{{ error | escape }}</p>
|
||||
{% endfor %}
|
||||
|
@ -43,7 +47,7 @@
|
|||
<div class="column">
|
||||
<p>
|
||||
<label class="label" for="id_end_date">End date:</label>
|
||||
<input type="date" name="end_date" class="input" id="id_end_date">
|
||||
<input type="date" name="end_date" class="input" id="id_end_date" value="{{ form.end_date.value|date:'Y-m-d' }}">
|
||||
{% for error in form.end_date.errors %}
|
||||
<p class="help is-danger">{{ error | escape }}</p>
|
||||
{% endfor %}
|
||||
|
|
|
@ -81,6 +81,7 @@ class Announcement(View):
|
|||
form = forms.AnnouncementForm(request.POST, instance=announcement)
|
||||
if form.is_valid():
|
||||
announcement = form.save()
|
||||
form = forms.AnnouncementForm(instance=announcement)
|
||||
data = {
|
||||
"announcement": announcement,
|
||||
"form": form,
|
||||
|
|
Loading…
Reference in a new issue