I have created a Listings Page where all listings can be searched. From there, a user can click on any particular listing to see further detail. When I go to individual listing page, I am displaying Breadcrumb to provide an option to go back to Search results (which was previous Listings page).
The issue is I am not able to pass 2 parameters (one containing the previous URL so that I can use that for Breadcrumb back to search results) while calling individual listing page from listings page. Please see main code:
views.py
def listing(request, listing_id, query):
listing = get_object_or_404(Listing, pk=listing_id)
context = {
'listing': listing,
'query':query
}
return render(request, 'listings/listing.html', context)
HTML template
{% url 'listing' listing_id=listing.id path=12 %}
I tried using {{ request.get_full_path }} to find path and then add to parameter but its not working.
Any suggestions on how to capture URL will be appreciated.