Answer the question
In order to leave comments, you need to log in
How to get the last value in the current path (url) in Django?
Good afternoon!
In the existing template, it is necessary to show (know) the last value in the current url,
I tried this option: {% if request.get_full_path|last == counter %}
(counter in this case is a known value, a certain number that is taken from the database)
The code works, but unfortunately last takes only 1 character if the value is in url /foo /bar/12 then 2 is taken, and I need to take 12.
I understand that using |last is not an option, you can’t use split in the template ...
How to split request.get_full_path and select its last value? write a function in view ?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question