Skip to content Skip to sidebar Skip to footer

Using Zipped Queryset Many Times In Template

I have a model that is only a string : class Data(models.Model): string = models.CharField(max_length=200); There are 2 registered instances of the model in my database. It is

Solution 1:

In Python 3, zip will give you an iterator, meaning it will be consumed on the first loop and therefore not print anything on the second loop.

You can fix this by casting the iterator to a list, replacing zip(data, data2) with list(zip(data, data2)).

Post a Comment for "Using Zipped Queryset Many Times In Template"