Commit ac643c3f by Alex Gaynor

Fixed #58 -- capfirst verbose_name when creating the label for form fields, the…

Fixed #58 -- capfirst verbose_name when creating the label for form fields, the same way django's builtin fields do.
parent f2647973
from django.contrib.contenttypes.generic import GenericRelation from django.contrib.contenttypes.generic import GenericRelation
from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.models import ContentType
from django.db import models from django.db import models
from django.db.models.fields.related import ManyToManyRel, RelatedField from django.db.models.fields.related import ManyToManyRel, RelatedField, add_lazy_relation
from django.db.models.related import RelatedObject from django.db.models.related import RelatedObject
from django.db.models.fields.related import add_lazy_relation from django.utils.text import capfirst
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from taggit.forms import TagField from taggit.forms import TagField
...@@ -92,7 +92,7 @@ class TaggableManager(RelatedField): ...@@ -92,7 +92,7 @@ class TaggableManager(RelatedField):
def formfield(self, form_class=TagField, **kwargs): def formfield(self, form_class=TagField, **kwargs):
defaults = { defaults = {
"label": self.verbose_name, "label": capfirst(self.verbose_name),
"help_text": self.help_text, "help_text": self.help_text,
"required": not self.blank "required": not self.blank
} }
......
...@@ -367,7 +367,7 @@ class TaggableFormTestCase(BaseTaggingTestCase): ...@@ -367,7 +367,7 @@ class TaggableFormTestCase(BaseTaggingTestCase):
def test_formfield(self): def test_formfield(self):
tm = TaggableManager(verbose_name='categories', help_text='Add some categories', blank=True) tm = TaggableManager(verbose_name='categories', help_text='Add some categories', blank=True)
ff = tm.formfield() ff = tm.formfield()
self.assertEqual(ff.label, 'categories') self.assertEqual(ff.label, 'Categories')
self.assertEqual(ff.help_text, u'Add some categories') self.assertEqual(ff.help_text, u'Add some categories')
self.assertEqual(ff.required, False) self.assertEqual(ff.required, False)
......
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