M
M
maksam072021-02-19 15:20:48
Django
maksam07, 2021-02-19 15:20:48

How to exclude existing rows for CharField(choices)?

There is a field, let's say:

CUSTOM_CHOICES = [
    ('0', '0'),
    ('1', '1'),
    ('2', '2'),
    ('3', '3'),
]
choice = models.CharField(max_length=2, choices=CUSTOM_CHOICES, default=0, unique=True, )

Because Since it is unique, it makes no sense to display values ​​that are in existing rows. I would like to know what solutions can be here?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question