You are not logged in.

Change Language:

Freelancer? Consultant? Check out: WorkTrail - Time Tracking made easy
Board » Django » Templates » delete duplicates from django filters

Hi,
From my for loop i am getting duplicate from my database like(14,14,15,16,16).Here how to remove duplicates here,
Is there any django "filter",or How to write template tags for this.

<select name = "loadEp" method = 'get' >
{% for eachEp in GetEpisodes %}
<option value = "{{ eachEp.epName }}">{{ eachEp.epName }} </option>
{% endfor %}
</select>

Thanks.
Firstly, you should explain how getEpisodes is working, is it a context_processor variable, or are you passing it in from the view?

This is how you should write it out in your template:
{% for ep in episode_list %}
ep.pk - ep.name
{% endfor %}
Where episode_list is sent in from the view as such:
render("template.html", {'episode_list':Episode.objects.filter(yadayada)})

If done correctly, you should never get duplicates, and for the love of god, you should use the primary_key to confirm if their indeed duplicates or not. I highly doubt that they are, or they shouldn't be if your using the ORM correctly.





Powered by Sphene Community Tools