Я безуспешно пытаюсь определить две разные таблицы в моем представлении на основе классов с помощью MultiTableMixin из django_tables2.
Таблицы ссылаются на одну и ту же модель.
tables.py
class PrescriptionsTable(tables.Table):
class Meta:
#define the model
model = Prescription
template_name = 'django_tables2/bootstrap4.html'
sequence = ("id", "patient","status")
class PrescriptionsTable2(tables.Table):
class Meta:
#define the model
model = Prescription
template_name = 'django_tables2/bootstrap4.html'
sequence = ("id", "patient","status")
filters.py
class PrescriptionFilter(django_filters.FilterSet):
patient = django_filters.CharFilter(lookup_expr='icontains')
class Meta:
model = Prescription
fields = ['id','patient','status']
views.py
class PrescriptionListView(LoginRequiredMixin,MultiTableMixin, TemplateView):
template_name='prescriptions/prescription_list2.html'
tables = []
filterset_class = PrescriptionFilter
def get_context_data(self, **kwargs):
context = super(PrescriptionListView, self).get_context_data(**kwargs)
table=Prescription.objects.filter(created__gte=date(2018, 10, 1))
context['table'] =table
has_filter = any(field in self.request.GET for field in set(self.filterset_class.get_fields()))
context['has_filter'] = has_filter
return context
Как я могуопределить мой взгляд и, в частности, список таблиц для достижения MultiTableMixin?
Эта ссылка на источник не помогла https://django -tables2.readthedocs.io / en / latest /страницы / родовое-mixins.html