Login

Tag "split"

Snippet List

split in html template

Html içinde split ile kesme Kesme işleminden sonra kaçıncı bloğun okunacağını düzeltebilme {% kes request.path "/" 3 4 %} gelenveri.split("/")[3:4]

  • template
  • html
  • simple_tag
  • split
Read More

Split a string to a list and add to select options

The template filter is use for split a string such as "foo|foobar|bar" to select option widget. You can define the splitter of the string by yourself. **Usage:** Add the code into templatetags folder of a installed app, then add below code into your template file. ` {% load split_as_option %} <select name="widget_name"> {{ QuerySet.values|split_as_option:"|" }} </select> `

  • template
  • filter
  • split
Read More

TemplateTag to Split a List into Uniform Chunks

Creates a template tag called "split_list" which can split a list into chunks of a given size. For instance, if you have a list 'some_data', and you want to put it into a table with three items per row, you could use this tag: {% split_list some_data as chunked_data 3 %} Given a some_data of [1,2,3,4,5,6], the context variable 'chunked_data' becomes [[1,2,3],[4,5,6]] This is useful for creating rows of equal numbers of items. Thanks to the users of #django (pauladamsmith, Adam_G, and ubernostrum) for advice and pointers, thanks to Guyon Mor&eacute;e for writing the chunking recipe that this tag is based on.

  • templatetag
  • split
  • list
Read More

split filter

**Usage** (*in template*): <img src="{{ MEDIA_URL }}2007/images/{% filter split:","|random %}theimage1.jpg,something2.jpg,thirdisthecharm.jpg{% endfilter %}" /> I decided to make it simple, because one template creator wanted to add random images to different places of templates. Creating something huge, like external image filename parsing was not necessary in this case.

  • filter
  • split
Read More

4 snippets posted so far.