Skip to content

Commit

Permalink
Added support for blank=True
Browse files Browse the repository at this point in the history
  • Loading branch information
gvangool committed Sep 27, 2010
1 parent 73c6fad commit 7fe3a0b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion taggit/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@ def __init__(self, to):


class TaggableManager(RelatedField):
def __init__(self, verbose_name=_("Tags"), help_text=None, through=None):
def __init__(self, verbose_name=_("Tags"), help_text=None, through=None, blank=False):
self.use_gfk = through is None or issubclass(through, GenericTaggedItemBase)
self.through = through or TaggedItem
self.rel = TaggableRel(to=self.through._meta.get_field("tag").rel.to)
self.verbose_name = verbose_name
self.help_text = help_text or _("A comma-separated list of tags.")
self.blank = blank
self.editable = True
self.unique = False
self.creates_table = False
Expand Down Expand Up @@ -77,6 +78,7 @@ def formfield(self, form_class=TagField, **kwargs):
defaults = {
"label": self.verbose_name,
"help_text": self.help_text,
"required": not self.blank
}
defaults.update(kwargs)
return form_class(**defaults)
Expand Down

0 comments on commit 7fe3a0b

Please sign in to comment.