Giter Site home page Giter Site logo

nanderson94 / django-taggit-serializer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from glemmapaul/django-taggit-serializer

0.0 3.0 0.0 39 KB

The Django Taggit Serializer Created for the Django REST Framework

License: BSD 3-Clause "New" or "Revised" License

Makefile 11.92% Python 88.08%

django-taggit-serializer's Introduction

Django Taggit Rest Serializer

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!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.