Skip to content

Instantly share code, notes, and snippets.

@edgabaldi
Created June 23, 2015 18:18
Show Gist options
  • Select an option

  • Save edgabaldi/0a460a7c4e2b6ea7f23a to your computer and use it in GitHub Desktop.

Select an option

Save edgabaldi/0a460a7c4e2b6ea7f23a to your computer and use it in GitHub Desktop.
Custom template example of ModelFormSetView (django-extra-views)
{% extends 'agendamento/base_comitente.html' %}
{% load bootstrap %}
{% block extra_css %}
<style>
.form-actions{
padding:10px;
background-color:#EEE;
border-top:1px solid #CCC;
}
</style>
{% endblock extra_css %}
{% block content_comitente %}
<h3>Cadastro de Categoria</h3>
<form method="post">{% csrf_token %}
{{ formset.management_form }}
<table class="table table-bordered table-splited">
<tr>
<th>Nome Categoria</th>
<th>Pontos</th>
<th>Excluir</th>
</tr>
{% for form in formset %}
<tr>
<td>{{form.nome_categoria}}</td>
<td>{{form.pontos}}</td>
<td>{{form.DELETE}}{{form.id}}</td>
</tr>
{% endfor %}
</table>
<div class="form-group form-actions">
<button class="btn btn-success">Salvar</button>
</div>
</form>
{% endblock content_comitente %}
from extra_views import ModelFormSetView
class CapacidadeCategoriaFormSetView(ModelFormSetView):
model=CapacidadeCategoria
template_name='agendamento/capacidadecategoria_form.html'
can_delete=True
@abpostman1
Copy link

abpostman1 commented Oct 21, 2021

can_delete=True
didn't work for me. Had to use :

factory_kwargs = {'can_delete': True}
(Django 3.2.7)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment