On Sep 17, 1:04 pm, andreas schmid <a.schmi...@gmail.com> wrote:
> hi,
>
> i have 3 models topic, project, technology. a topic contains projects
> and projects have technolgies.
> the 3 models are related to each other by foreignkeys in the project model.
>
> in the topic detail view i need to have the projects within the given
> topic which works with a wrapper around the object_detail view (generic)
> wich topic.projects_set.all() and a for loop in the template.
>
> i get the technologies for the projects too like this:
>
> {% for project in object_list  %}
>         {% for technology in project.technologies.all %}
>             <a href="{{ technology.get_absolute_url }}">{{
> technology.title }}</a>
>             {% if forloop.last %}{% else %}
>             {% ifequal forloop.revcounter0 1 %}and {% else %}, {%
> endifequal %}
>             {% endif %}
>         {% endfor %}
>     {% endfor %}
>
> but of course the same technology shows up multiple times if more
> projects use the same technology.
> how can i get the technologies as a distinct list?
>
> do i have to get the queryset in the view? (if yes how?) o
> r is there a way to get distinct results also in a template?

Use distinct(), not all() (which evidently works in templates well for
any queryset).
--~--~---------~--~----~------------~-------~--~----~
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