# HG changeset patch # User neko259 # Date 2015-04-14 18:43:14 # Node ID ee1fd20015f52539f4abe251332dfa881ce0d6b4 # Parent e990ce466b1f0416359c78b2812470d5e4fd285e Refactored required tags validation a bit diff --git a/boards/forms.py b/boards/forms.py --- a/boards/forms.py +++ b/boards/forms.py @@ -333,11 +333,11 @@ class ThreadForm(PostForm): required_tag_exists = False for tag in tags.split(): - tag_model = Tag.objects.filter(name=tag.strip().lower(), - required=True) - if tag_model.exists(): - required_tag_exists = True + try: + Tag.objects.get(name=tag.strip().lower(), required=True) break + except ObjectDoesNotExist: + pass if not required_tag_exists: all_tags = Tag.objects.filter(required=True)