src/hdalab/management/commands/query_geo_inclusion.py
changeset 359 46ad324f6fe4
parent 283 7a7035d3f7c9
child 693 09e00f38d177
--- a/src/hdalab/management/commands/query_geo_inclusion.py	Fri Nov 14 17:06:02 2014 +0100
+++ b/src/hdalab/management/commands/query_geo_inclusion.py	Sun Nov 16 18:09:42 2014 +0100
@@ -17,6 +17,9 @@
     def handle_noargs(self, **options):
         self.style = no_style()
 
+        GeoInclusion.objects.all().delete()
+        Country.objects.all().delete()
+
         qs = Tag.objects.filter(category__label="Localisation").exclude(dbpedia_uri = None)
         total = qs.count()
         
@@ -48,13 +51,13 @@
                 if re.match(resourceprefix, resourceuri):
                     countrytxt = re.findall('([^/]+$)', resourceuri)[0]
                     
-                    country, created = Country.objects.get_or_create(dbpedia_uri=resourceuri)
+                    country, _ = Country.objects.get_or_create(dbpedia_uri=resourceuri)
                     GeoInclusion.objects.get_or_create(tag=tag, country=country)
                     
                 if resourceuri == identityuri:
                     countrytxt = '<is a country>'
                     
-                    country, created = Country.objects.get_or_create(dbpedia_uri=tag.dbpedia_uri)
+                    country, _ = Country.objects.get_or_create(dbpedia_uri=tag.dbpedia_uri)
                     GeoInclusion.objects.get_or_create(tag=tag, country=country)
                 
             else: