Thursday, October 27, 2011

How to create unique tags based on Taggit

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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment