stop repetition in template

2011-05-04 Thread pankaj sharma
hello friends, i have database of colleges. i want to show all cities so what is did is.. in template.. {% for college in list %} {{college.city}} {% endfor %} in views.py def list(request): college_list=College.objects.all() return render_

Re: stop repetition in template

2011-05-04 Thread Brian Bouterse
I would handle this at the views layer. Right now your queryset of college_list is a list of colleges containing cities. In your view code I would re-organize it to be a list of cities that contain colleges. Then you can iterate through cities and get colleges. You can build this data structure

Re: stop repetition in template

2011-05-04 Thread Javier Guerra Giraldez
On Wed, May 4, 2011 at 11:42 AM, pankaj sharma wrote: > in template.. > >               {% for college in list %} >                {{college.city}} >               {% endfor %} > > in views.py > > def list(request): >    college_list=College.objects.all() >    return render_to_response( >    'coll

Re: stop repetition in template

2011-05-04 Thread Brian Bouterse
I like your second solution a lot better than mine. I've never seen {% ifchanged %} used properly before. Brian On Wed, May 4, 2011 at 1:19 PM, Javier Guerra Giraldez wrote: > On Wed, May 4, 2011 at 11:42 AM, pankaj sharma > wrote: > > in template.. > > > > {% for college in list

Re: stop repetition in template

2011-05-04 Thread pankaj sharma
actually i want both.. like LIST OF ALL COLLEGES: college1 city1 college2 city2 college3 city3 LIST OF CITIES city1 city2 city3 {but is city2 = city3} then it would show : LIST OF ALL COLLEGES: college1 city1 college2 city2 college3 city3 LIST OF CITIES city1 city2 --