0

I have a url which is generated using {{request.get_ull_path}}. I want to split and get last part of it using django template tag.

<a  href="{{ request.get_full_path }}">

which gives me

abc.me/profile/bio/

How can I get only last part (bio) using django template tag? Or do I have to write custom template tag?

MysticCodes
  • 3,092
  • 5
  • 25
  • 33
  • This answer might help you: http://stackoverflow.com/questions/5352455/obtain-the-first-part-of-an-url-from-django-template. However, @Jbertrand is correct with his logic. – jape Dec 08 '16 at 15:25

1 Answers1

2

You should not do this kind of thing in a template. Django intentionally discourage you from doing too much processing in template. You should just split before rendering the view.

See this post : Django templates - split string to array

Community
  • 1
  • 1
Jbertrand
  • 419
  • 1
  • 4
  • 14