django-multiforloop

An enhancement to Django's builtin forloop template tag
Download

django-multiforloop Ranking & Summary

Advertisement

  • Rating:
  • License:
  • LGPL
  • Publisher Name:
  • Gabriel Grant

django-multiforloop Tags


django-multiforloop Description

An enhancement to Django's builtin forloop template tag django-multiforloop is a Django app that provides an enhancement to django's builtin forloop template tag, which makes it easier to iterate over multiple lists simultaneously (acting similarly to Python's `zip`).multiforloop allows this Python idiom to be used in django templates:for x,y in zip(x_list, y_list): print x,yNormally, to iterate over multiple lists simultaneously in django templates, the lists must be zipped in the view and passed in as an extra context variable. When this is the only extra processing needed in a view (eg. with generic views), this can result in a fair bit of unneeded boilerplate code.Usage:Rendering this template {% load multifor %} {% for x in x_list; y in y_list %} {{ x }}:{{ y }} {% endfor %}with this context context = { "x_list": ('one', 1, 'carrot'), "y_list": ('two', 2, 'orange') }will output one:two 1:2 carrot:orangeInstallation:1. pip install django-multiforloop2. Include 'multiforloop' in your settings.py's list of installed apps3. Add `{% load multifor %}` to the top of any templates which use the multiforloop Requirements: · Python · Django


django-multiforloop Related Software