• This repository has been archived on 10/May/2023
  • Stars
    star
    164
  • Rank 228,742 (Top 5 %)
  • Language
    Python
  • License
    BSD 3-Clause "New...
  • Created over 9 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

The Django Taggit Serializer Created for the Django REST Framework

Django Taggit Rest Serializer

โš ๏ธโš ๏ธโš ๏ธ

WARNING This project is not maintained anymore, it is now vendored into the main django-taggit project, documentation on Django Rest Framework integration can be found here:

https://django-taggit.readthedocs.io/en/latest/serializers.html

Thank you all - you lovely people - for your contributations and/or usage! <3

Build Status

About

This package is meant for the django-taggit package which is available here

The django-taggit package makes it possible to tag a certain module.

Installation

To install this package you can use the following pip installation:

pip install django-taggit-serializer

Then, add taggit_serializer to your Settings in INSTALLED_APPS:

    INSTALLED_APS = (
        ...
        'taggit_serializer',
    )

Usage

Because the tags in django-taggit need to be added into a TaggableManager() we cannot use the usual Serializer that we get from Django REST Framework. Because this is trying to save the tags into a list, which will throw an exception.

To accept tags through a REST API call we need to add the following to our Serializer:

from taggit_serializer.serializers import (TagListSerializerField,
                                           TaggitSerializer)


class YourSerializer(TaggitSerializer, serializers.ModelSerializer):

    tags = TagListSerializerField()

    class Meta:
        model = YourModel

And you're done, so now you can add tags to your model

Contribute

Please feel free to create pull requests and issues!