Table view changed to separate class tables.py

This commit is contained in:
ferdzo
2023-04-19 19:26:04 +02:00
parent aa6b2cc679
commit bbdba33e38
3 changed files with 11 additions and 5 deletions

View File

@@ -6,4 +6,8 @@ class InsertTable(tables.Table):
class Meta:
model = Insert
template_name = "serviceCRM/list.html"
attrs = {'class':'table table-sm'}
fields = ['id', 'name', 'phone', 'description', 'date', 'done', 'edit']
edit = tables.TemplateColumn(template_name='serviceCRM/edit.html')

View File

@@ -0,0 +1 @@
<a class="btn btn-info btn-sm" href="{% url 'training_update' record.id %}">Open</a>

View File

@@ -1,9 +1,10 @@
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import get_object_or_404, render
from .models import Insert
from django.views import generic
from .forms import InputForm
from .tables import InsertTable
from .models import Insert
from django_tables2 import SingleTableView
# from django.template import loader
@@ -30,7 +31,6 @@ class ReportById(generic.DetailView):
class InsertNew(generic.View):
model = Insert
template_name = "serviceCRM/form.html"
def insert(request):
if request.method == 'POST':
form = InputForm(request.POST)
@@ -44,9 +44,10 @@ class InsertNew(generic.View):
return render(request, InsertNew.template_name, {'form': form})
class List(generic.ListView):
class List(SingleTableView):
model = Insert
template_name = "serviceCRM/list.html"
table_class = InsertTable
template_name = 'serviceCRM/list.html'
def done(request, question_id):