Get anchor and all params in request path


For a development with django, I try to get the parameters of my url.
my path :
candy is my view avec #bubblizz is my id anchor.

A lot of documentation on request items but impossible to find how to get the anchor

{{ request.build_absolute_uri }}   =>
{{ request.get_full_path }}        => /categories/candy
{{ request.path }}                 => /categories/candy
{{ request.META.PATH_INFO}}        => /categories/candy

The goal is to test the presence of the anchor in the url.

{% if bubblizz in request.anchor %}Yeah{% endif %}

Does anyone have an idea? Or documentation that might help?



The part after the hash is called the fragment [wiki], these are not send to the server, as is specified in the Wikipedia article:

Clients are not supposed to send URI fragments to servers when they retrieve a document, and without help from a local application (see below) fragments do not participate in HTTP redirections.

Django thus never is given the #bubblizz part of the URI. You will need to work with some JavaScript to detect the fragment, and for example make an AJAX query and update the DOM accordingly. You can do this with window.location.hash [mdn] to get the fragment for the URI of the window.

Answered By – Willem Van Onsem

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published