[Answered ]-Django navigation as POST input for dynamcial view

1👍

You can use get request to the views when one of the option is clicked. For example:

In the base.html navigtion section, your list item will be like

<li>
    <a href="{% url 'get-city-data' city=city2 %}">
        <span class="title">City 2</span>
    </a>
</li>

so your urls.py be something like

urlpatterns = [
    # your existing urls
    path('get-city-data/<str:city>/', get_city_data, name='get-city-data'),
]

And views be like

def get_city_data(request, city=None):
    # your logic here to return data filter by city
    context = {} # populate with required context
    return render(request, 'city.html', context)

0👍

You can create a new View like /city/str:cityname, get the info about city and use your existing template that render details about city.

in your base.html, you can put the href like this city/City1. It should make the get request to this view /city/str:cityname.

👤Alexon

Leave a comment