Save author along with added edition

This commit is contained in:
Mouse Reeve 2022-02-25 16:54:03 -08:00
parent c67f92af46
commit b001c31f97
2 changed files with 2 additions and 3 deletions

View file

@ -126,10 +126,9 @@
<div class="box">
{% if book.authors.exists %}
{# preserve authors if the book is unsaved #}
{{ form.authors.as_hidden }}
<input type="hidden" name="authors" value="{% for author in book.authors %}{{ author.id }},{% endfor %}">
<fieldset>
{% for author in book.authors.all %}
{{ form.authors.as_hidden }}
<div class="is-flex is-justify-content-space-between">
<label class="label mb-2">
<input type="checkbox" name="remove_authors" value="{{ author.id }}" {% if author.id|stringformat:"i" in remove_authors %}checked{% endif %} aria-describedby="desc_remove_author_{{author.id}}">

View file

@ -150,7 +150,7 @@ class CreateBook(View):
data["form"].data = formcopy
return TemplateResponse(request, "book/edit/edit_book.html", data)
book = form.save(commit=False)
book = form.save()
parent_work = get_object_or_404(models.Work, id=parent_work_id)
book.parent_work = parent_work