I'm learning Django, so far so good, however I am stuck with the get_query(self)
function.
I have two models in django no foreign in tables:
class Airport(models.Model): ID = models.AutoField() Name = models.CharField() City = models.CharField() ICAO = models.CharField() class Airport_Frequency(models.Model): ICAO = models.CharField()) ATC_Type = models.CharField() Frequency_MHz = models.DecimalField()
Now I want to create a listview but I want to join table fields Airport.name
and Airport_Frequency.ICAO
to show in frequency list - SQL statement:
SELECT DISTINCT a.ICAO, b.ICAO, b.Name FROM airport as b, airport_frequency as a WHERE a.ICAO = b.ICAO
View:
class Airport_FrequencyListView(ListView): model = Airport_Frequency
How to refer in the Airport_FrequencyListViewview
above to another model?
没有评论:
发表评论