Merge pull request #35 from taavi/better-word-limit-error-message
Provides a better error message when a sponsor benefit text field is lon...
This commit is contained in:
commit
7c3d4f2912
1 changed files with 5 additions and 2 deletions
|
@ -194,8 +194,11 @@ class SponsorBenefit(models.Model):
|
|||
return u"%s - %s" % (self.sponsor, self.benefit)
|
||||
|
||||
def clean(self):
|
||||
if self.max_words and len(self.text.split()) > self.max_words:
|
||||
raise ValidationError("Sponsorship level only allows for %s words." % self.max_words)
|
||||
num_words = len(self.text.split())
|
||||
if self.max_words and num_words > self.max_words:
|
||||
raise ValidationError(
|
||||
"Sponsorship level only allows for %s words, you provided %d." % (
|
||||
self.max_words, num_words))
|
||||
|
||||
def data_fields(self):
|
||||
"""
|
||||
|
|
Loading…
Reference in a new issue