Commit 24b8b7ba by Adam Greig

Set serialize=False on TaggableManager to fix tagged object serializing

parent 91791c87
...@@ -73,7 +73,7 @@ class ExtraJoinRestriction(object): ...@@ -73,7 +73,7 @@ class ExtraJoinRestriction(object):
class TaggableManager(RelatedField, Field): class TaggableManager(RelatedField, Field):
def __init__(self, verbose_name=_("Tags"), def __init__(self, verbose_name=_("Tags"),
help_text=_("A comma-separated list of tags."), through=None, blank=False): help_text=_("A comma-separated list of tags."), through=None, blank=False):
Field.__init__(self, verbose_name=verbose_name, help_text=help_text, blank=blank) Field.__init__(self, verbose_name=verbose_name, help_text=help_text, blank=blank, null=True, serialize=False)
self.through = through or TaggedItem self.through = through or TaggedItem
self.rel = TaggableRel(self) self.rel = TaggableRel(self)
......
...@@ -5,6 +5,7 @@ from unittest import TestCase as UnitTestCase ...@@ -5,6 +5,7 @@ from unittest import TestCase as UnitTestCase
import django import django
from django.conf import settings from django.conf import settings
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.core import serializers
from django.db import connection from django.db import connection
from django.test import TestCase, TransactionTestCase from django.test import TestCase, TransactionTestCase
from django.utils import six from django.utils import six
...@@ -336,6 +337,10 @@ class TaggableManagerTestCase(BaseTaggingTestCase): ...@@ -336,6 +337,10 @@ class TaggableManagerTestCase(BaseTaggingTestCase):
apple.tags.add('red') apple.tags.add('red')
self.assertEqual(list(apple.tags.slugs()), ['green-and-juicy', 'red']) self.assertEqual(list(apple.tags.slugs()), ['green-and-juicy', 'red'])
def test_serializes(self):
apple = self.food_model.objects.create(name="apple")
serializers.serialize("json", (apple,))
class TaggableManagerDirectTestCase(TaggableManagerTestCase): class TaggableManagerDirectTestCase(TaggableManagerTestCase):
food_model = DirectFood food_model = DirectFood
......
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