individual models for each tagged field in Product
This commit is contained in:
@@ -2,11 +2,34 @@ from django.contrib.gis.db import models
|
||||
|
||||
from tagulous.models import SingleTagField, TagField, TagTreeModel
|
||||
|
||||
from core.models import TreeTag
|
||||
from companies.models import Company
|
||||
|
||||
# Create your models here.
|
||||
|
||||
class TreeTag(TagTreeModel):
|
||||
class TagMeta:
|
||||
initial = ""
|
||||
force_lowercase = True
|
||||
max_count=20
|
||||
# autocomplete_view = 'myapp.views.hobbies_autocomplete'
|
||||
|
||||
|
||||
class CategoryTag(TagTreeModel):
|
||||
class TagMeta:
|
||||
initial = ""
|
||||
force_lowercase = True
|
||||
max_count=20
|
||||
# autocomplete_view = 'myapp.views.hobbies_autocomplete'
|
||||
|
||||
|
||||
class AttributeTag(TagTreeModel):
|
||||
class TagMeta:
|
||||
initial = ""
|
||||
force_lowercase = True
|
||||
max_count=20
|
||||
# autocomplete_view = 'myapp.views.hobbies_autocomplete'
|
||||
|
||||
|
||||
|
||||
class Product(models.Model):
|
||||
|
||||
@@ -35,8 +58,8 @@ class Product(models.Model):
|
||||
discount = models.DecimalField('Descuento', max_digits=5, decimal_places=2, null=True, blank=True)
|
||||
stock = models.PositiveIntegerField('Stock', null=True, blank=True)
|
||||
tags = TagField(to=TreeTag)
|
||||
category = SingleTagField(null=True, blank=True) # main tag category
|
||||
attributes = TagField(to=TreeTag, related_name='product_attributes')
|
||||
category = SingleTagField(to=CategoryTag, null=True, blank=True) # main tag category
|
||||
attributes = TagField(to=AttributeTag, related_name='product_attributes')
|
||||
identifiers = models.TextField('Identificador único de producto', null=True, blank=True)
|
||||
|
||||
# internal
|
||||
|
||||
@@ -318,7 +318,7 @@ class ProductViewSetTest(APITestCase):
|
||||
'discount': '0.05',
|
||||
'stock': 22,
|
||||
'tags': ['tag1x, tag2x'],
|
||||
'category': 'MayorTagCategory2',
|
||||
'category': 'mayortagcategory2',
|
||||
'attributes': ['color/blue', 'size/m'],
|
||||
'identifiers': '34rf34f43c43',
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user