register inclusion_tag project footer_geo html def footer_geo items li

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
@register.inclusion_tag('project/footer_geo.html')
def footer_geo():
items = list(Country.objects.all())
# Brainf*cking code :D
count = 4
size, mod = divmod(len(items), count)
sizes = [size] * count
for x in xrange(mod):
sizes[0] += 1
columns = []
for size in sizes:
columns.append(items[:size])
del items[:size]
return {'columns': columns,
}