mirror of https://github.com/snachodog/mybuddy.git
Use Taggit serializer for taggable models
This commit is contained in:
parent
834e7636fc
commit
dd0ba29416
|
@ -6,7 +6,7 @@ from rest_framework.exceptions import ValidationError
|
|||
from django.contrib.auth.models import User
|
||||
from django.utils import timezone
|
||||
|
||||
from taggit.serializers import TagListSerializerField
|
||||
from taggit.serializers import TagListSerializerField, TaggitSerializer
|
||||
|
||||
from core import models
|
||||
|
||||
|
@ -107,7 +107,7 @@ class CoreModelWithDurationSerializer(CoreModelSerializer):
|
|||
return attrs
|
||||
|
||||
|
||||
class TaggableSerializer(serializers.HyperlinkedModelSerializer):
|
||||
class TaggableSerializer(TaggitSerializer, serializers.HyperlinkedModelSerializer):
|
||||
tags = TagListSerializerField(required=False)
|
||||
|
||||
|
||||
|
|
|
@ -632,6 +632,8 @@ class TagsAPITestCase(TestBase.BabyBuddyAPITestCaseBase):
|
|||
response = self.client.post(reverse("api:note-list"), data, format="json")
|
||||
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
|
||||
self.assertEqual(response.data["tags"], data["tags"])
|
||||
note = models.Note.objects.get(pk=response.data["id"])
|
||||
self.assertEqual(list(note.tags.names()), data["tags"])
|
||||
|
||||
|
||||
class TemperatureAPITestCase(TestBase.BabyBuddyAPITestCaseBase):
|
||||
|
|
Loading…
Reference in New Issue