hi, Tsung: your code for i in range(0,len(tags)): if tags[i] not in s: s.append(tags[i]) the tags[i] will return the tag.__unicode__() function and compare with the s List, so you will get the complete List as the beginning. If you want get your hope result, you can use the django core function:distinct(). Hope this can help you.
2011/10/27 Tsung-Hsien <jasoniem9...@gmail.com> > I use Taggit to create a list of tags, and want to create unique tags > of the list. > I have a list as below > tags=[[<Tag: R>], [<Tag: Living>], [<Tag: Python>], [<Tag: Living>], > [<Tag: Living>],[<Tag: Living>], [<Tag: Living>], [<Tag: weather>]] > > and write this > for i in range(0,len(tags)): > if tags[i] not in s: > s.append(tags[i]) > > However, the output s is same as tags. > > s=[[<Tag: R>], [<Tag: Living>], [<Tag: Python>], [<Tag: Living>], > [<Tag: Living>],[<Tag: Living>], [<Tag: Living>], [<Tag: weather>]] > > How to get s=[[<Tag: R>], [<Tag: Living>], [<Tag: Python>], [<Tag: > weather>]] > > thanks!! > > -- > 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. > > -- 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.