first custom tag seriliazer tests
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
from django.contrib.gis.db import models
|
||||
|
||||
from tagulous.models import SingleTagField, TagField
|
||||
|
||||
from companies.models import Company
|
||||
|
||||
# Create your models here.
|
||||
@@ -30,9 +32,9 @@ class Product(models.Model):
|
||||
update_date = models.DateTimeField('Fecha de actualización de producto', null=True, blank=True)
|
||||
discount = models.DecimalField('Descuento', max_digits=5, decimal_places=2, null=True, blank=True)
|
||||
stock = models.PositiveIntegerField('Stock', null=True)
|
||||
# tags = models.ManyToMany(Tag, null=True, blank=True )
|
||||
# category = models.ForeignKey(Tag, null=true) # main tag category
|
||||
# attributes = models.ManyToMany(Tag, null=True, blank=True )
|
||||
tags = TagField( )
|
||||
category = SingleTagField() # main tag category
|
||||
attributes = TagField()
|
||||
identifiers = models.TextField('Identificador único de producto', null=True, blank=True)
|
||||
|
||||
# internal
|
||||
|
||||
@@ -1,8 +1,17 @@
|
||||
from rest_framework import serializers
|
||||
|
||||
from taggit_serializer.serializers import TagListSerializerField, TaggitSerializer
|
||||
from products.models import Product
|
||||
|
||||
from utils.tag_serializers import SingleTagSerializerField
|
||||
|
||||
class ProductSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = Product
|
||||
exclude = ['created', 'updated', 'creator']
|
||||
|
||||
class ProductSerializer(TaggitSerializer, serializers.ModelSerializer):
|
||||
|
||||
tags = TagListSerializerField( )
|
||||
category = SingleTagSerializerField() # main tag category
|
||||
attributes = TagListSerializerField()
|
||||
|
||||
class Meta:
|
||||
model = Product
|
||||
exclude = ['created', 'updated', 'creator']
|
||||
|
||||
Reference in New Issue
Block a user