Q
Q
Quiab2021-05-13 22:04:18
Django
Quiab, 2021-05-13 22:04:18

How to make a table field able to store one unique value (True) and many others (False)?

Hello!
Prompt ways to implement the following logic:
I have a table, rules. Each entry is a separate set of rules, among which there is an activity flag field. If True, the rules are active, if False, respectively, no
Rules are specified in django-admin. And I understand that I can crutch this situation in other places. but I want it at the level of the model. Challenge: Only One set of rules can be active at a time. In other words, if the field value is True, it must be unique, if the value is False, uniqueness is not checked
How to implement this in Django

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
maksam07, 2021-05-16
@maksam07

https://docs.djangoproject.com/en/3.2/ref/validators/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question