fixed issue of products deleted if category tag deleted
This commit is contained in:
@@ -18,7 +18,6 @@ class CategoryTag(TagTreeModel):
|
||||
class TagMeta:
|
||||
initial = ""
|
||||
force_lowercase = True
|
||||
max_count=20
|
||||
# autocomplete_view = 'myapp.views.hobbies_autocomplete'
|
||||
|
||||
|
||||
@@ -58,15 +57,15 @@ 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(to=CategoryTag, null=True, blank=True) # main tag category
|
||||
category = SingleTagField(to=CategoryTag, null=True, blank=True, on_delete=models.SET_NULL) # main tag category
|
||||
attributes = TagField(to=AttributeTag, related_name='product_attributes')
|
||||
identifiers = models.TextField('Identificador único de producto', null=True, blank=True)
|
||||
|
||||
# internal
|
||||
created = models.DateTimeField('date of creation', auto_now_add=True)
|
||||
updated = models.DateTimeField('date last update', auto_now=True)
|
||||
creator = models.ForeignKey('core.CustomUser', on_delete=models.DO_NOTHING, null=True, related_name='product')
|
||||
history = models.ForeignKey('history.HistorySync', on_delete=models.DO_NOTHING, null=True, related_name='product')
|
||||
creator = models.ForeignKey('core.CustomUser', on_delete=models.SET_NULL, null=True, related_name='product')
|
||||
history = models.ForeignKey('history.HistorySync', on_delete=models.SET_NULL, null=True, related_name='product')
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.name} / {self.sku}"
|
||||
|
||||
Reference in New Issue
Block a user