Render the formset correctly
This commit is contained in:
parent
84dd14bddb
commit
694a845aae
6 changed files with 18 additions and 14 deletions
|
@ -1,4 +1,4 @@
|
|||
{% load staticfiles %}
|
||||
{% load static %}
|
||||
{% load bulma_utils %}
|
||||
{% load i18n %}
|
||||
|
||||
|
|
4
elections/templates/elections/forms/formset.html
Normal file
4
elections/templates/elections/forms/formset.html
Normal file
|
@ -0,0 +1,4 @@
|
|||
{{ formset.management_form }}
|
||||
{% for form in formset %}
|
||||
{% include "elections/forms/form.html" %}
|
||||
{% endfor %}
|
|
@ -10,7 +10,7 @@
|
|||
<form action="" method="post">
|
||||
{% csrf_token %}
|
||||
|
||||
{{ vote_form }}
|
||||
{% include "elections/forms/formset.html" %}
|
||||
|
||||
<div class="field">
|
||||
<p class="control">
|
||||
|
|
|
@ -6,7 +6,7 @@ from django.urls import reverse
|
|||
from django.utils.translation import gettext_lazy as _
|
||||
from django.views.generic import CreateView, DetailView, UpdateView
|
||||
|
||||
from .forms import OptionFormSet
|
||||
from .forms import ElectionCreateForm, OptionFormSet
|
||||
from .models import Election, Option, Question
|
||||
|
||||
# TODO: access control *everywhere*
|
||||
|
@ -14,8 +14,8 @@ from .models import Election, Option, Question
|
|||
|
||||
class ElectionCreateView(SuccessMessageMixin, CreateView):
|
||||
model = Election
|
||||
form_class = ElectionCreateForm
|
||||
template_name = "elections/election_create.html"
|
||||
fields = ["name", "description", "start_time", "end_time"]
|
||||
success_message = _("Élection crée avec succès !")
|
||||
|
||||
|
||||
|
@ -65,7 +65,7 @@ class VoteView(SuccessMessageMixin, DetailView):
|
|||
self.object = self.get_object()
|
||||
vote_form = OptionFormSet(instance=self.object)
|
||||
|
||||
return self.render_to_response(self.get_context_data(vote_form=vote_form))
|
||||
return self.render_to_response(self.get_context_data(formset=vote_form))
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
self.object = self.get_object()
|
||||
|
|
Loading…
Reference in a new issue