Answer the question
In order to leave comments, you need to log in
How to select multiple statuses at once in django?
model:
class EbayProduct(models.Model):
class Status(models.IntegerChoices):
EBAY_PRODUCT = 0, 'Ebay product'
READY_TO_LIST = 1, 'Ready to list'
LISTINGS_TO_REMOVE = 2, 'Listings to remove'
PRICE_UPDATE_NEEDED = 3, 'Price Update Needed'
NO_WEIGHT = 4, 'No weight or weight = 0'
NO_IMAGES = 5, 'No images'
UPC_EAN_GTIN_NOT_ASSIGNED = 6, 'UPC/EAN/GTIN not assigned'
NO_EBAY_CATEGORIES = 7, 'No ebay categories'
PRODUCT_SWITCHED = 8, 'Products Switched off for this selling site'
UPDATE_BLOCKED = 9, 'Update Blocked'
''' fields '''
product = models.OneToOneField(Product, on_delete=models.CASCADE, related_name='for_ebay')
status = models.SmallIntegerField(choices=Status.choices, default=Status.EBAY_PRODUCT, verbose_name='status')
Answer the question
In order to leave comments, you need to log in
for example, replace SmallIntegerField with JSONField, but you will have to manually fill it
You can remember what bits are, And just set / check the corresponding bits in the number.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question