editor: check for duplicate redirect slugs with a single query
This commit is contained in:
parent
f55ea561bd
commit
8000c00e2a
1 changed files with 5 additions and 4 deletions
|
@ -70,10 +70,11 @@ class MapitemFormMixin(ModelForm):
|
|||
|
||||
for slug in self.add_redirect_slugs:
|
||||
self.fields['slug'].run_validators(slug)
|
||||
if LocationSlug.objects.filter(slug=slug).exists():
|
||||
raise ValidationError(
|
||||
_('Can not add redirecting slug “%s”: it is already used elsewhere.') % slug
|
||||
)
|
||||
|
||||
for slug in LocationSlug.objects.filter(slug__in=self.add_redirect_slugs).values_list('slug', flat=True)[:1]:
|
||||
raise ValidationError(
|
||||
_('Can not add redirecting slug “%s”: it is already used elsewhere.') % slug
|
||||
)
|
||||
|
||||
def clean(self):
|
||||
if 'geometry' in self.fields:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue