|
Posted by ramesh03 |
|
|
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. |
|
|
Posted by Kevin Veroneau |
|
|
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. |


