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 dynamically in the view code without explicitly pre-defining it as
a class or model.

Hope this helps.

Brian

On Wed, May 4, 2011 at 12:42 PM, pankaj sharma
<new.pankajsha...@gmail.com>wrote:

> 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_to_response(
>    'college/list.html',
>    {'list':college_list}
>    )
>
>
>
> so suppose i have two colleges in one city so it is showing the city
> name twice  .. so how do i stop repetition..
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Brian Bouterse
ITng Services

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to