Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

removing duplicates from django models data

for duplicates in Tag.objects.values("name").annotate(
    records=Count("name")
).filter(records__gt=1):
    for tag in Tag.objects.filter(name=duplicates["name"])[1:]:
        tag.delete()
Source by www.djangotricks.com #
 
PREVIOUS NEXT
Tagged: #removing #duplicates #django #models #data
ADD COMMENT
Topic
Name
3+7 =