[Fixed]-Detail View is not displaying details of the post? Django

1đź‘Ť

In addition to the issues pointed out by other posters, you have an issue with your urls.py. You do not terminate the pattern for your index view, so it matches everything that starts with “aircraft” – which includes “aircraftdetail”. You should use $ consistently:

url(r'^admin/', admin.site.urls),
url(r'^aircraft/$', 'aircraft.views.browseaircraft', name='browseaircraft'),
url(r'^aircraftdetail/(?P<pk>\d+)/$', 'aircraft.views. aircraft_detail_view', name='aircraftdetail'),]

0đź‘Ť

Well, your aircraft_detail.html loops over all aircrafts and displays their information. If you want to only show information for the one selected aircraft, you’ll need to change the html page to something like this:

{% block content %}
    <h1>Title: {{ aircraft.title }}</h1>
    {{ aircraft.cost }}
    {{ aircraft.range}}
    {{ aircraft.cost }}
    {{ aircraft.cruise_speed }}
{% endblock %}
👤NS0

Leave a comment