Clarification that you request:
Airport → Airport_Frequnecy thi is one to many. One airport can have a lot of freq.
Airport list view should show a list of airports with ICAO. Airport Details will show all Airport fields details + frequency correspondingto the airport
Frequency list view should show ICAO and airport names with link (under ICAO) to Frequency detail list for particular aitrport.
so it means when i’m callin get_absolute_url on airport object ( whicch is a result of qurery in Airport_Frequency in this case) → called get_absolute_url will be the one from it’s model (Airport in this case)
I’m sorry, I’m getting confused when you make multiple references to different pages. I’m trying to focus in on the one specific page for which you’re identifying this issue. I understand that you may have different questions on your different views, but let’s try to address these one at a time.
My assumption from the view names is that we’re currently looking to address this one:
So to repeat my earlier questions:
What is this to be a list of? (Airport, or Airport_Frequency?)
For each entry in this list, what data do you want displayed?
What do you want to get a URL for? (I’m guessing a detailed page for either Airport or Airport_Frequency, which one?)
That’s a nice site layout and explains the direction you’re going. But again, to avoid confusion, I’m trying to focus on just one page, the page that started this discussion. So to clarify for this one specific view that we’re talking about here, is this the page we’re discussing for this issue?
Indeed. And this page shows only airports that have a freq. It works fine with custom query that you share at the begining of our discussion. However the issue is now the link (blue fonts in the picture)
Cool. So, assuming that your detail page (what the links refer to) is a named url, perhaps something like path('frequency_list/<int:airport_id>/', FrequencyListForAirport.as_view(), name='airport-frequency-list'),
Then your template can render that part of the line as something like: <a href="{% reverse "airport-frequency-list" airport.id %}>{{airport.icao}}</a>
(Typing this off-the-cuff - there may be an error/typo or two - hopefully this is close enough to give you some ideas.)
I know it’s mostly a matter of personal taste, but I don’t see the value of using a regex for the path here. I find path('frequency/<int:pk>', ... to be far more readable.
I thought ICAO was an attribute of an Airport and not of Airport_Frequency? (At least, that’s the case in your model at the top of this thread.)
{% for af in airport_frequency_list %}
<tr>
...
<td>{{af.airport.Name}}</td>
<td>{{af.airport.ICAO}}</td>
</tr>
{% endfor%}
It works fine, however just an extra question:
If all freq. concern to an airport ( the same id in airport ID column), how can refer to airport id once for example if I would like to place airport name before " Frequency details" header. e.g.: