-class Location(Entity):
- name = models.CharField(max_length=150, blank=True)
- description = models.TextField(blank=True)
-
- longitude = models.FloatField(blank=True, validators=[MinValueValidator(-180), MaxValueValidator(180)])
- latitude = models.FloatField(blank=True, validators=[MinValueValidator(-90), MaxValueValidator(90)])
-
- events = GenericRelation('Event')
-
- def clean(self):
- if not (self.name or self.description) or (self.longitude is None and self.latitude is None):
- raise ValidationError("Either a name and description or a latitude and longitude must be defined.")
-
- class Meta:
- abstract = True