Login

Tag "shuffle"

Snippet List

shuffle templatetag

This is useful for randomizing an iterable of objects in place in a django template. Usage: {% load shuffle %} {# now some_list is ordered #} {% shuffle some_list %} {# now some_list is randomized #}

  • template-tag
  • iterable
  • shuffle
Read More

Real shuffle function

This function solve the issue of random.shuffle that is based only on randomized shuffling (that's not a real shuffling, because many times items returned aren't shuffled enough). This function make a randomized shuffle and after this loops long the list resorting to avoid two items with a same value in a given attribute. When shuffling is over and there are duplicates, they are leftover to the end (and you can remove them if you set 'remove_duplicates' to True) Run it in a separated file to see it in action.

  • shuffle
Read More

2 snippets posted so far.