Alex,

Once again sir you have shown me the light. Thank you.

On Feb 20, 7:59 pm, Alex Gaynor <alex.gay...@gmail.com> wrote:
> On Fri, Feb 20, 2009 at 7:58 PM, nixon66 <nixon....@gmail.com> wrote:
>
> > tried
>
> > Place.objects.values_list('county', flat=true).distinct()
>
> > Now its not returning any values.
>
> > On Feb 20, 7:49 pm, Alex Gaynor <alex.gay...@gmail.com> wrote:
> > > On Fri, Feb 20, 2009 at 7:46 PM, nixon66 <nixon....@gmail.com> wrote:
>
> > > > I'm using this in a template to get a list of items in the list.
>
> > > > <ul>
> > > > {% for item in list %}
> > > >    <li>{{ item.var }}</li>
> > > > {% endfor %}
> > > > </ul>
>
> > > > The problem is that I get duplicate values when I do this. So if var1
> > > > appears in my database more than once, I get it as many times as it
> > > > appears. I looked at using the distinct() function but could not quite
> > > > figure out how to get it to work the way I want. Any suggestions?
> > > > Thanks in advance.
>
> > > If you only want to print one value from the items you can do something
> > > like:
>
> > > Model.objects.values_list('field', flat=True).distinct()
>
> > > that will return a list of all the values in that field, but distint of
> > > course.
>
> > > Alex
>
> > > --
> > > "I disapprove of what you say, but I will defend to the death your right
> > to
> > > say it." --Voltaire
> > > "The people's good is the highest law."--Cicero
>
> It doesn't return models anymore, it just returns the individual items so
> isntead of
>
> {% for item in lst  %}
>    {{ item.var }}
> {% endfor %}
>
> you would do
>
> {% for item in lst %}
>    {{ item }}
> {% endfor %}
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero
--~--~---------~--~----~------------~-------~--~----~
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