Im making shop on django and cant realize how to solve the problem:
I got class Product(class for clothes) and i need to create another class for Sizes of different categories of clothes, for example:
Shoes will got – 9US, 10US, 11US…
Shirts will got – XS, S, M, L…
etc.
How can i create that type of class??
My Product class:
class Product(models.Model):
class ModerationStatuses(models.TextChoices):
DRAFT = 'DR', _('черновик')
ON_MODERATION = 'MD', _('На модерации')
APPROVED = 'AP', _('Одобрено')
REJECTED = 'RJ', _('Отклонено')
class ConditionStatuses(models.TextChoices):
NEW = 'NEW', _('New')
USED = 'USD', _('Used')
VERY_WORN = 'VW', _('Very worn')
NOT_SPECIFIED = 'NS', _('Not specified')
title = models.CharField(max_length=100)
price = models.DecimalField(max_digits=6, decimal_places=2)
quantity = models.IntegerField()
city = ...
style = models.ForeignKey(Style, related_name='category_products', on_delete=models.CASCADE, null=True, blank=True)
category = models.ForeignKey(Category, related_name='style_products', on_delete=models.CASCADE, null=True, blank=True)
address = models.CharField(max_length=250)
description = models.TextField()
brand = models.CharField(max_length=150)
published = models.BooleanField(default=False, null=False)
modification = models.OneToOneField('self', on_delete=models.CASCADE, null=True, blank=True,
help_text='When editing an approved item a modification is created. This '
'modification is sent for moderation and, after approval, replaces '
'the original position.')
is_modification = models.BooleanField(default=False)
moderation_status = models.CharField(choices=ModerationStatuses.choices, default=ModerationStatuses.DRAFT,
null=False, max_length= 2)
condition = models.CharField(choices=ConditionStatuses.choices, default=ConditionStatuses.NEW, null=False, max_length=3)
posted_at = models.DateTimeField(auto_now_add=True)
def __str__(self):
return self.title
I literally cant find any info to solve my problem(((
New contributor
vllscarf is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.