diff --git a/core/models/caves.py b/core/models/caves.py index 1155f81..91453fc 100644 --- a/core/models/caves.py +++ b/core/models/caves.py @@ -81,7 +81,7 @@ class CaveAndEntrance(models.Model): class Cave(TroggleModel): # too much here perhaps, - area = models.ManyToManyField(Area, blank=True) + area = models.ManyToManyField(Area, blank=False) depth = models.CharField(max_length=100, blank=True, null=True) description_file = models.CharField(max_length=200, blank=True, null=True) entrances = models.ManyToManyField("Entrance", through="CaveAndEntrance") @@ -101,7 +101,7 @@ class Cave(TroggleModel): underground_centre_line = models.TextField(blank=True, null=True) underground_description = models.TextField(blank=True, null=True) unofficial_number = models.CharField(max_length=60, blank=True, null=True) - url = models.CharField(max_length=200, blank=True, null=True) + url = models.CharField(max_length=200, blank=True, null=True, unique = True) # class Meta: # unique_together = (("area", "kataster_number"), ("area", "unofficial_number")) @@ -188,9 +188,12 @@ class Cave(TroggleModel): return qms # a QuerySet def kat_area(self): - for a in self.area.all(): - if a.kat_area(): - return a.kat_area() + try: + for a in self.area.all(): + if a.kat_area(): + return a.kat_area() + except: + return "" def entrances(self): return CaveAndEntrance.objects.filter(cave=self)