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.
- [Answered ]-Django custom permissions not being recognized?
- [Answered ]-Django forms: two form models in one <form> with a foreign key
- [Answered ]-Viewflow.io: What is the recommended pattern to go a step back in a flow?
- [Answered ]-How to get the "overall" counter of an object in a group in a Django template?
- [Answered ]-Cannot populate backbone collection from backbone.js tutorial
Source:stackexchange.com