Skip to content

Instantly share code, notes, and snippets.

class FlightTable(tables.Table):
class Meta:
model = Flight
fields = ('ff_number','ff_from__fullname','ff_from__country','ff_to__fullname')
class FlightFilter(django_filters.FilterSet):
full_name = django_filters.CharFilter(field_name="ff_from__fullname", label="Search location", lookup_expr="icontains")
class Meta:
model = Flight
from django.db import models
class Airport(models.Model):
code = models.CharField(max_length=4)
fullname = models.CharField(max_length=50)
country = models.CharField(max_length=50)
def __str__(self):
return self.fullname
from django.shortcuts import render
from django.views.generic import ListView,View
import django_tables2 as tables
from .models import Flight,FlightCo
from django_filters.views import FilterView
from django_tables2.views import SingleTableMixin
import django_filters
# Create your views here.
class Index(View):