def clean_location(self): name = self.cleaned_data['location'] try: get_location_id(name) return name except: raise ValidationError('Location does not exist.')
def get_location_id(self): return get_location_id(self.location)