Reputation: 77
I have following list which i need to parse in django template.
['000.223.4.00/24|Network a', '000.000.00.0/25|Network b', '10.000.1.0/24|Network c']
Basically, i want to separate network and network name part already separated by '|'. Any idea of how to achieve it in django. I had been doing it with indexof() and substring methods in jquery. looking for a similar thing.
Upvotes: 1
Views: 332
Reputation: 705
You can't do it in django templates using built in tags and filters.
The right way to do it - parse it in view by python code and pass it to template as list of separated items.
But if it is principal for you to do it in django templates - you can write custom template filter. https://docs.djangoproject.com/en/3.0/howto/custom-template-tags/#writing-custom-template-filters
Upvotes: 1