Commit 107a42c8 by Scott Duckworth

change error message when key name already exists

parent 70d4e6d2
......@@ -30,7 +30,8 @@ class UserKey(models.Model):
objects = type(self).objects.exclude(
if exclude is None or 'name' not in exclude:
if objects.filter(user=self.user,
raise ValidationError({'name': ['A key with this name already exists']})
message = 'You already have a key with that name'
raise ValidationError({'name': [message]})
if exclude is None or 'key' not in exclude:
other = objects.get(fingerprint=self.fingerprint, key=self.key)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment