summaryrefslogtreecommitdiff
path: root/ishtar_common/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'ishtar_common/models.py')
-rw-r--r--ishtar_common/models.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/ishtar_common/models.py b/ishtar_common/models.py
index 5dd9ddee1..f0552d3eb 100644
--- a/ishtar_common/models.py
+++ b/ishtar_common/models.py
@@ -2657,6 +2657,11 @@ if settings.COUNTRY == 'fr':
(self.name, unicode(self.arrondissement)))
+class TownManager(models.Manager):
+ def get_by_natural_key(self, numero_insee, year):
+ return self.get(numero_insee=numero_insee, year=year)
+
+
class Town(Imported, models.Model):
name = models.CharField(_(u"Name"), max_length=100)
surface = models.IntegerField(_(u"Surface (m2)"), blank=True, null=True)
@@ -2685,6 +2690,9 @@ class Town(Imported, models.Model):
ordering = ['numero_insee']
unique_together = (('numero_insee', 'year'),)
+ def natural_key(self):
+ return (self.numero_insee, self.year)
+
def __unicode__(self):
if self.cached_label:
return self.cached_label